![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| command line args 2 | skooly5 | UNIX for Dummies Questions & Answers | 2 | 04-06-2008 06:36 PM |
| command line args | skooly5 | UNIX for Dummies Questions & Answers | 2 | 04-06-2008 04:46 PM |
| Command line args | enuenu | High Level Programming | 2 | 05-28-2007 09:19 PM |
| Solaris 'format' output without args...? | SunDude | SUN Solaris | 3 | 05-24-2007 01:09 PM |
| Args to Array | Shaz | Shell Programming and Scripting | 2 | 06-30-2003 01:11 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
alias with args how to ...
Hello ( sorry newbie question )
I don’t understand something im trying to make simple alias that takes 1 arg but it don’t gives me the desire result here is what I have : stlist | awk '{print "ls -l "$2}' now I want to translate it to alias that takes instead of the $2 one arg so I did : alias stlistdir "stlist | awk '{print "ls -l "\!*}'" also tried: alias stlistdir "stlist | awk '{print "ls-l $"\!*}'" but didn’t get the desire results, im getting only the print of the second column when I type : stylistic 2 stlistdir without the ls –l , why ? |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
It is simple, you only see the command in standard output because you are just printing in awk and you not executing the command.
Could you post the output of stlist command, you want to do ls -lrt to the output of 2nd column of stlist command ? |
|
#3
|
|||
|
|||
|
well this is the thing I don’t what it to execute the ls-l command, only to print it
so the output will be when I run the alias stlist 2 for instance: ls –l file1 ls –l file2 ls –l file3 |
|
#4
|
|||
|
|||
|
alias stlistdir "stlist | awk '{print "ls -l "\!*}'"
If you see the above statment, you are using double quotes in two places, one for alias and one for awk.... it obviously mismatch... try this in ksh alias stlistdir ="stlist | sed 's/^/ls -l /g'" The following statement also not working as well.. stlist | awk '{print "ls -l "$2}' there should be a "," before $2. |
|
#5
|
|||
|
|||
|
I guess I didn’t explain my self very well
what I need simply is transform this one liner stlist | awk '{print "ls -l "$2}' where stlist is simple program that gives me list of files from repository and from the output of this stlist command I want to take the second column ( this is the file name ) and add the "ls –l" command, now in the alias I want to make the $2 part as argument that is sometime the user will get the second column or third depends on the number he typed in the alias I hope I made my self clear now thanks |
|||
| Google The UNIX and Linux Forums |