Operating System - HP-UX
1827429 Members
3895 Online
109965 Solutions
New Discussion

Re: Can a soft link be created for an option of a command

 
DipuK
Occasional Contributor

Can a soft link be created for an option of a command

Hi,
Is it possible for me to create a soft link for an option of a command.
Eg: I can use "ln -s /sbin/ls my_ls" for creating a soft link for ls as my_ls in my current directory.

Now suppose I want to creat a soft link for ls -l explicitly. I mean i want an executable which has the functionality of ls -l is it possible.

I know this can be done in a simple manner with the alias command. But for curiosity I would like to know is there a method with ln

Cheers!!!!
Dipu
4 REPLIES 4
James R. Ferguson
Acclaimed Contributor

Re: Can a soft link be created for an option of a command

Hi:

Sorry, no. There is no place within the inode to store the information.

Regards!

...JRF...
Pete Randall
Outstanding Contributor

Re: Can a soft link be created for an option of a command

Dipu,

It sounds to me that what you really need is an alias. In your "shrc" file for your shell, put the following line:

alias my_ls="ls -l"



Pete

Pete
Suhas_2
Regular Advisor

Re: Can a soft link be created for an option of a command

Hi Dipu,
If at all you want to do this, you can write simple one line scripts, which would internally invoke the commands in the specified directory with necessary arguments.
For example,
1> the contents of my_ls could be
/usr/bin/ls -l | pg

2> the contents of my_top could be
/usr/bin/top -m 10

3> A typical my_iostat would look like
iostat 1 10

These tools would prove handy in the long run.
I would follow this practice but with shorter command names.((;~))

Regards'
Suhas.
Never say "Die"
Bill Douglass
Esteemed Contributor

Re: Can a soft link be created for an option of a command

You can store the arguments along with the pathname in the symlink file. However, the system will treat the whole string as a pathname, rather then parsing it into a pathname and arguments.


So the following works:

ln -s "/usr/bin/ls" xyz
./xyz



While doing this fails:

ln -s "/usr/bin/ls -l" xyz
./xyz

-bash: ./xyz: No such file or directory