The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Alias a command b_garima UNIX for Advanced & Expert Users 2 10-22-2007 10:06 AM
a question about alias command jayyu317 UNIX for Dummies Questions & Answers 1 12-11-2006 11:07 PM
alias for rm command shriashishpatil UNIX for Advanced & Expert Users 8 02-23-2006 08:42 AM
AWK embeded PERL bionicfysh Shell Programming and Scripting 7 09-23-2003 11:55 AM
How to define two variable in foreach command?? geoquest Shell Programming and Scripting 14 08-22-2002 06:11 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-29-2007
jfortes jfortes is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 6
Angry 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.
  #2 (permalink)  
Old 05-29-2007
suparnbector suparnbector is offline
Registered User
  
 

Join Date: May 2007
Posts: 13
Need More details...

Please provide the output of psme command...
  #3 (permalink)  
Old 05-29-2007
jfortes jfortes is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 6
Unhappy

psme output:

tstuser 63122 rating
oppuser 12134 javapps

meaning: first column is the user , second is the process id, third is the application name

Cheers.
  #4 (permalink)  
Old 05-30-2007
suparnbector suparnbector is offline
Registered User
  
 

Join Date: May 2007
Posts: 13
Try This...

alias fnm='ls -ltr | awk {print $9}'
  #5 (permalink)  
Old 05-30-2007
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,355
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 "[i]fw -r"
Another simplification : group grep and awk in a single awk command :
Code:
awk "/[i]ifw -r/ { print \\$2 }"
Jean-Pierre.
  #6 (permalink)  
Old 06-05-2007
jfortes jfortes is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 6
Thumbs up Resolved

Hi all,

Thanks for your suggestions.

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

worked perfectly.

Regards,
Joao.
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 02:33 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0