Re: bash: process substitution not working in script
- From: Ed Morton <morton@xxxxxxxxxxxxxx>
- Date: Tue, 29 Apr 2008 13:42:02 -0500
On 4/29/2008 1:03 PM, lihao0129@xxxxxxxxx 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,"/");print
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
help 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.
.
- Follow-Ups:
- Re: bash: process substitution not working in script
- From: lihao0129@xxxxxxxxx
- Re: bash: process substitution not working in script
- References:
- bash: process substitution not working in script
- From: lihao0129@xxxxxxxxx
- bash: process substitution not working in script
- Prev by Date: Re: bash: process substitution not working in script
- Next by Date: Re: rsync most recent files from large source
- Previous by thread: Re: bash: process substitution not working in script
- Next by thread: Re: bash: process substitution not working in script
- Index(es):
Relevant Pages
|
|