bug-bash
[Top][All Lists]
Advanced

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

xargs combined with awk


From: giuseppe . amatulli
Subject: xargs combined with awk
Date: Thu, 20 Dec 2012 07:43:50 -0800 (PST)
User-agent: G2/1.0

Hi,
have this a for loop which is sending the "dir" variable one for each processor.


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"

join -1 2  -2 1 $IN_UA/$dir/UA_block_sum_s.txt     $IN_UA/$dir/UA_popD_all.txt  
     > $IN_UA/$dir/UA_block_sum_popD.txt
join -1 2  -2 1 $IN_UA/$dir/UA_block_sum_popD.txt  
$IN_UA/$dir/UA_hunitD_all.txt > $IN_UA/$dir/UA_block_sum_popD_hunitD.txt

' _ 

The loop works fine, no issues. 
When i'm insert an awk command in the -c ' ' _     
I get an error. 

e.g. 


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

' _


awk: cmd. line:1: {
awk: cmd. line:1:  ^ unexpected newline or end of string


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?

I would like to avoid to create an external script and called it by 
xargs bash myscript.sh 

thanks in advance 
Giuseppe 











reply via email to

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