The UNIX Forums
"Join the Network of UNIX System Users"


 
Subject: define an alias with an embeded awk command ??
CYBERAY
Newbie
Rank: 1



UID 102
Digest Posts 0
Credits 0
Posts 73
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at Jun 20, 2007 10:24 AM  Profile | P.M. 
define an alias with an embeded awk command ??



define an alias with an embeded awk command ??



hi all,

i'm trying to define an alias with an embeded awk command:

alias kpipe='kill `psme| grep "ifw -r" | grep -v "grep ifw -r"| awk '{print $2}'`'

the problem is that the awk command (awk '{print $2}') contains two ' ..' quotes. so bash assumes that the first awk quote corresponds to the end of the alias, but it's not. i want it to process till the last ' .


how do i do it ? any help will be highly appreciated.

note: i'm using bash shell.

thanks for you help.


Top
Eightrix
Newbie
Rank: 1



UID 132
Digest Posts 0
Credits 0
Posts 45
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at Jun 20, 2007 10:24 AM  Profile | P.M. 
need more details...
Top
arbonboy
Newbie
Rank: 1



UID 55
Digest Posts 0
Credits 0
Posts 35
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at Jun 20, 2007 10:24 AM  Profile | P.M. 
psme output:

tstuser 63122 rating
oppuser 12134 javapps

meaning: first column is the user , second is the process id, third is the application name
Top
InFlames
Newbie
Rank: 1



UID 186
Digest Posts 0
Credits 0
Posts 17
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at Jun 20, 2007 10:24 AM  Profile | P.M. 
try this...
Top
JKhoury
Newbie
Rank: 1



UID 203
Digest Posts 0
Credits 0
Posts 47
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at Jun 20, 2007 10:24 AM  Profile | P.M. 
code:
alias kpipe='kill `psme| grep "ifw -r" | grep -v "grep ifw -r"| awk "{print \\$2}"`'or

code:
alias kpipe="kill \`psme| grep 'ifw -r' | grep -v 'grep ifw -r'| awk '{print \$2}'\`"
you can simplify a little bit your command :
replace
code:
grep "ifw -r" | grep -v "grep ifw -r" by
code:
grep "fw -r"
another simplification : group grep and awk in a single awk command :
code:
awk "/ifw -r/ { print \\$2 }"
Top
 

 

All times are GMT, the time now is Jul 31, 2010 03:27 AM

Powered by Discuz! 5.0.0  © 2001-2006 UNIX Forums
Processed in 0.005900 second(s), 8 queries

Clear Cookies - Contact Us - UNIX Help - Archiver - WAP