The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


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 !!

More UNIX and Linux Forum Topics You Might Find Helpful
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

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 12-28-2005
Registered User
 

Join Date: Aug 2005
Posts: 229
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 ?
Reply With Quote
Forum Sponsor
  #2  
Old 12-28-2005
Registered User
 

Join Date: Dec 2005
Location: London
Posts: 222
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 ?
Reply With Quote
  #3  
Old 12-28-2005
Registered User
 

Join Date: Aug 2005
Posts: 229
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
Reply With Quote
  #4  
Old 12-28-2005
Registered User
 

Join Date: Dec 2005
Location: London
Posts: 222
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.
Reply With Quote
  #5  
Old 12-28-2005
Registered User
 

Join Date: Aug 2005
Posts: 229
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
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 10:55 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0