Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

awk alias is not working 1

Status
Not open for further replies.

rigstars1

Instructor
Oct 2, 2010
19
US
I need help setting this up as an alias in bash. I can't get it working. Please help.



top -l 1 | awk '/PhysMem/ {print "Used: " $8 " Free: " $10}'?
 
put it in a script and alias that script

[tt]alias t=/path/to/topawkscript[/tt]

otherwise you'll have some difficulty hiding or escaping the different shell metacharacters

[tt]alias t="top -l 1 | awk '/ ... /\{print \"Used: \" \$8 ... \}'"[/tt]

HTH,

p5wizard
 
Hi

Why an alias and not a shell function ?
Code:
[COLOR=darkgoldenrod]function t()[/color] { top -l [purple]1[/purple] [teal]|[/teal] awk [green][i]'/PhysMem/ {print "Used: " $8 " Free: " $10}'[/i][/green]?[teal];[/teal] }
You can put its definition in your ~/.bashrc and you can invoke it with just its name.


Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top