Oct 2, 2010 #1 rigstars1 Instructor Joined Oct 2, 2010 Messages 19 Location 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}'?
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}'?
Oct 3, 2010 #2 p5wizard IS-IT--Management Joined Apr 18, 2005 Messages 3,165 Location BE 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 Upvote 0 Downvote
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
Oct 3, 2010 1 #3 feherke Programmer Joined Aug 5, 2002 Messages 9,541 Location RO 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. http://free.rootshell.be/~feherke/ Upvote 0 Downvote
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. http://free.rootshell.be/~feherke/