[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: xargs combined with awk
From: |
giuseppe . amatulli |
Subject: |
Re: xargs combined with awk |
Date: |
Fri, 21 Dec 2012 13:14:34 -0800 (PST) |
User-agent: |
G2/1.0 |
thanks to all of you.
in the end i selected
the following solution
-c $' .... awk \'{}\' .... '
all the best
giuseppe
On Thursday, 20 December 2012 09:43:50 UTC-6, giuseppe...@gmail.com wrote:
> 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