LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-20-2009, 08:16 PM   #1
.:neogeo:.
LQ Newbie
 
Registered: May 2006
Posts: 18

Rep: Reputation: 0
escape characters in watch command


Hi all,

Need a little help running this command.

watch -d 'ps aux | awk '{print $4"\t"$11}' | sort | uniq -c | awk '{print $2" "$1" "$3}' | sort -nr | head'

I get this error message from AWK. awk: cmd. line:1: {print awk: cmd. line:1: ^ unexpected newline or end of string


I have tried all the usual by trying to escape the single and double quotes in the command but same result. The end result should be the a listing of memory hungry processes that are scanned every 2 seconds ( watch default value )

Any suggestions are welcomed.

Geo.
 
Old 10-20-2009, 11:59 PM   #2
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Bookworm (Fluxbox WM)
Posts: 1,391
Blog Entries: 54

Rep: Reputation: 360Reputation: 360Reputation: 360Reputation: 360
Code:
watch -d 'ps aux | awk '\''{print $4"\t"$11}'\'' | sort | uniq -c | awk '\''{print $2" "$1" "$3}'\'' | sort -nr | head'
The trick is to exit the quoting, followed by the escaped quote, then reenter the quoting. Looks messy, but it works. A nicer way would be to put the command inside a script...

Last edited by neonsignal; 10-21-2009 at 12:01 AM.
 
1 members found this post helpful.
Old 10-21-2009, 02:23 AM   #3
.:neogeo:.
LQ Newbie
 
Registered: May 2006
Posts: 18

Original Poster
Rep: Reputation: 0
Thanks neonsignal! it worked like a charm. It has been a while since i done anything useful on bash and forgot about those little tricks.

Geo.
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Paths and escape characters code-breaker Linux - Newbie 4 07-11-2006 11:24 PM
passing escape characters along with lp command zita Linux - General 0 10-05-2005 01:58 PM
Variables and escape characters? flobadon Programming 4 09-10-2005 04:34 PM
Escape Characters in linux shunraj Linux - Software 1 05-18-2004 03:21 PM
escape characters not escaping BobNz Linux - Software 2 04-09-2004 03:34 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration