|
Search Forums:
|
|||||||
| Forums | Register | Forum Rules | Linux and Unix Links | Man Pages | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
Puzzled with hexdump, hd and ln
How to create a symbolic link to a command with certain argument?
When I man hexdump, it is said in the man page that "-C Canonical hex+ASCII display...Calling the command hd implies this option". Actually it is. hd equals to hexdump -C. And then I examined the ln command but find it is a symbolic link to hexdump, just like this: /usr/bin/hd -> hexdump. But I failed to make such a symbolic link like this. I tried: ln -s "/bin/ls -al" myls. But it didn't work. I wonder how to make a symbolic link to a command with certain argument. Thanks. |
| Sponsored Links | |
|
|
|
#2
|
||||
|
||||
|
Short answer: you can't Long answer: A symbolic link is just a reference to a different file. Basically it tells the OS "You were looking for file x, but to use it please load file y". However, since every program is told it's execution name as the very first parameter (even before those you specify on the command line), it can use different behaviour based on that name. But the program itself has to support that, and short of modifying the source you can't change the behaviour. What you can do instead is create an alias: Code:
alias myls="/bin/ls -la" |
| The Following User Says Thank You to pludi For This Useful Post: | ||
vistastar (07-30-2010) | ||
| Sponsored Links | ||
|
|
|
#3
|
|||
|
|||
|
Additional you can only like this so you cant not set options with command because this change the directive and there is no `ls -la` Code:
# ln -s "/bin/ls" myls # ./myls |
| The Following User Says Thank You to ygemici For This Useful Post: | ||
vistastar (07-30-2010) | ||
|
#4
|
||||
|
||||
|
@pludi: Thank you. That's interesting. I notice that the utility BusyBox behaves in the way you mentioned. Code:
lrwxrwxrwx 1 1004 1004 7 Jan 1 00:00 chgrp -> busybox lrwxrwxrwx 1 1004 1004 7 Jan 1 00:00 chmod -> busybox lrwxrwxrwx 1 1004 1004 7 Jan 1 00:00 chown -> busybox lrwxrwxrwx 1 1004 1004 7 Jan 1 00:00 cp -> busybox But, does the ln command have nothing to do with this feature? Is it only a trick of the program linked? Last edited by pludi; 07-31-2010 at 07:49 AM.. Reason: code tags, please... |
| Sponsored Links | |
|
|
#5
|
||||
|
||||
|
No, the ln command has nothing to do with it. The only thing it really does is call the symlink or link function, plus some validation. After all, a program is just a file, like a text file or image.
|
| Sponsored Links | |
|
|
#6
|
|||
|
|||
|
It does, and it doesn't. Busybox can detect what name it's called with and act accordingly; a trick its developers exploited to squeeze dozens of utilities into one medium executable. What you don't see happening is any arguments in those links. As described previously, that has to be done in the shell.
|
| Sponsored Links | ||
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Reverse hexdump without xxd | LessNux | Shell Programming and Scripting | 3 | 03-17-2010 01:02 AM |
| Puzzled over over the relationship between the partition and geometry of hard disk. | just.srad | Solaris | 5 | 12-08-2008 07:49 PM |
| puzzled with VxVM and iostat.. | samar | Solaris | 1 | 09-28-2008 09:18 AM |
| C++ Puzzled !! | RipClaw | Programming | 1 | 04-17-2005 11:18 PM |
| Puzzled with user ID. | lethefe | Programming | 4 | 07-15-2003 10:39 AM |
|
|