Afficher un message
Vieux 29/04/2008, 20h42   #3
Ed Morton
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: bash: process substitution not working in script

On 4/29/2008 1:03 PM, lihao0129@gmail.com wrote:
> I have a bash script which accept two input, one from a file, another
> from the output of a shell pipeline. thought I can use process
> substitution here, like:
>
> awk -F'.' '
> FNR == NR {
> # do_sth();
> next;
> } {
> # do_other_thing();
> }
> ' file1.txt <( find -type f -exec file {}
> + | \
> awk -F: '$2~/image/{split($1,b,"/")rint
> b[2]}' | \
> sort -nk1 | uniq -
> c' \
> )
>
> This works pretty well under command-line, but when I wrapped up
> exactly the above lines into a shell script(since I need to test over
> different directories), it did not work. the error shows:
>
>
>
> ./script.sh: line 30: syntax error near unexpected token `('
> ./script.sh: line 30: `' file1.txt <( find -type f -exec file {}
> + | \'
>
> I checked the man page about the process substitution which mentioned
> the named pipe. since I am not familiar with this part, could someone
> me with this problem? many thanks,
>


Since there's line-wrapping, etc. in your posting, it's hard to say what's
causing the problem, but in any case all you really need here is a pipeline:

find ... | awk ... | sort ... | uniq ... |
awk -F'.' '
FNR == NR {
# do_sth()
next
} {
# do_other_thing()
}
' file1.txt -

Note the "-" sign at the end to tell awk to read stdin after reading file1.txt.

Regards,

Ed.

  Réponse avec citation
 
Page generated in 0,06201 seconds with 9 queries