[ale] Stupid Bash Question

Geoffrey Myers lists at serioustechnology.com
Thu Mar 8 09:59:35 EST 2012



Sent from my iPhone

On Mar 8, 2012, at 7:18 AM, Mike Fletcher <fletch at phydeaux.org> wrote:

> 
> 
> On Mar 7, 2012, at 10:57 PM, Jim Kinney <jim.kinney at gmail.com> wrote:
> 
>> I don't recall the source but I read the backticks are to concidered deprecated.  Maybe in the bash 4 release notes?
>> 
> The $() form is the POSIX shell standard now IMSMR. All the kornish shells have supported it for a while now so it wouldn't surprise me to see it get deprecated

The original korn shell had $() since the beginning.

> 
> Also to nitpick on the original code:
> 
> * echoing the backticked output of hostname is kind of roundabout. Just run it
> 
> * the separate grep before awk could be replaced with just a single awk
> 
> awk '$0 !~ /swap/ {print $3}'
> 
> Or (for the whitespaceophobes :)
> 
> perl -lane '!/swap/&&print$F[2]'
> 
> 
>> On Mar 7, 2012 5:12 PM, "Michael Campbell" <michael.campbell at gmail.com> wrote:
>> One advantage of $() over `` is that you get matching opposing pairs of parens and nested commands are a bit easier to  parse.
>> 
>> echo $(foo bar $(baz blah) and then bleh)
>> 
>> as opposed to 
>> 
>> echo `foo bar `baz blah` and then bleh`    
>> 
>> 
>> For me another win is that I generally run shells inside emacs buffers so I can make use of the paren-matching feature from within emacs to help out.
>> 
>> 
>> On Wed, Mar 7, 2012 at 11:25 AM, Benjie <benjie.godfrey at gmail.com> wrote:
>> It looks like you missed placing a single quote after the 'echo `hostname` command.  That would prevent awk from interpreting its print command.
>> 
>> On Wed, Mar 7, 2012 at 11:07 AM, Brandon Colbert <colbert.brandon at gmail.com> wrote:
>> I am trying figure out what the heck is wrong with awk here.
>> 
>> for i in $(seq 1 1); do ssh 127.0.0.$i 'echo `hostname`; if [ `free -m | grep -i swap | awk '{print $3}'` > 1000 ]; then sudo echo reclaim; else echo hey; fi'; done
>> 
>> The command works, but I get an error about awk: Any suggestions?
>> 
>> deblapatl01
>> awk: cmd. line:1: {print
>> awk: cmd. line:1:       ^ unexpected newline or end of string
>> hey
>> 
>> 
>> _______________________________________________
>> Ale mailing list
>> Ale at ale.org
>> http://mail.ale.org/mailman/listinfo/ale
>> See JOBS, ANNOUNCE and SCHOOLS lists at
>> http://mail.ale.org/mailman/listinfo
>> 
>> 
>> 
>> 
>> -- 
>> "The most important thing to remember about drunks is that drunks are far more intelligent than non-drunks. They spend a lot of time talking in pubs, unlike workaholics who concentrate on their careers and ambitions, who never develop their higher spiritual values, who never explore the insides of their head like a drunk does."  -- Shane McGowan
>> 
>> _______________________________________________
>> Ale mailing list
>> Ale at ale.org
>> http://mail.ale.org/mailman/listinfo/ale
>> See JOBS, ANNOUNCE and SCHOOLS lists at
>> http://mail.ale.org/mailman/listinfo
>> 
>> 
>> 
>> _______________________________________________
>> Ale mailing list
>> Ale at ale.org
>> http://mail.ale.org/mailman/listinfo/ale
>> See JOBS, ANNOUNCE and SCHOOLS lists at
>> http://mail.ale.org/mailman/listinfo
>> 
>> _______________________________________________
>> Ale mailing list
>> Ale at ale.org
>> http://mail.ale.org/mailman/listinfo/ale
>> See JOBS, ANNOUNCE and SCHOOLS lists at
>> http://mail.ale.org/mailman/listinfo
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.ale.org/pipermail/ale/attachments/20120308/3810a548/attachment.html 


More information about the Ale mailing list