bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: xargs combined with awk


From: Greg Wooledge
Subject: Re: xargs combined with awk
Date: Thu, 20 Dec 2012 10:55:31 -0500
User-agent: Mutt/1.4.2.3i

On Thu, Dec 20, 2012 at 07:43:50AM -0800, address@hidden wrote:
> for dir in UA_tile_tif_pop_txt UA_buf10_tile_tif_pop_txt 
> UA_buf20_tile_tif_pop_txt UA_buf30_tile_tif_pop_txt UA_buf40_tile_tif_pop_txt 
> UA_buf50_tile_tif_pop_txt ; do echo $dir ; done | xargs  -n 1 -P 6 bash -c '
> IN_UA=/weldgfs/p51/gius_urban/pop_urban/buffer_tif
> dir="$1"
> 
> awk '{ print $2 }' $IN_UA/$dir/UA_block_sum_s.txt  > $IN_UA/$dir/test.txt
> 
> ' _

You are trying to use '...' inside '...'.

> I try to escape with the \ the ' and the } but no good results.
> any idea how how i can insert awk function in xargs bash -c '  '_ syntax?

The traditional way (works in all Bourne-family shells) would be to
close the outer '...', then use \', then re-open the '...'.  In practice
that looks like this:

  bash -c '
  awk '\''{print $2}'\'' ...
  ' _

Another way, which only works in bash, would be to use the $'...' quoting
syntax instead:

  bash -c $'
  awk \'{print $2}\' ...
  ' _

This really should have been asked on help-bash rather than bug-bash,
by the way.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]