Bash Process Substitution
I have a script like so:
#!/bin/bash while read x do sed -e 's/<Computer comp="\(.*\)" user="\(.*\)" password="\(.*\)">/\1 \2 \3/' <(echo -e "$x") done < <(cat archive_app.conf |grep -v '^#\\|^$') the script fails where I try to use process substitution yet this work from the command line .... now being that the command line and the script are both interpted via bash I would assume that this should work. the error that I get is this: blah.sh: line 5: syntax error near unexpected token `(' blah.sh: line 5: `sed -e 's/<Computer comp="\(.*\)" user="\(.*\)" password="\(.*\)">/\1 \2 \3/' <(echo -e "$x") ' I know that this is the case for when I take away the process substitutions I don't get the errors You help is very much welcomed. Thanks, Josh Holt |
Moved: This thread is more suitable in Programming and has been moved accordingly to help your thread/question get the exposure it deserves.
|
Have you tried piping the echo into the sed?
Code:
VAR=$(echo "$x" | sed 's/<Computer comp="\(.*\)" user="\(.*\)" password="\(.*\)">/\1 \2 \3/') |
Re: Bash Process Substitution
Quote:
I have the same problem ... On the command line: $ cat <(echo hello) <(echo world) hello world Inside script file: #!/bin/sh cat <(echo hello) <(echo world) When I execute the script I get: $ ./proc_sub.sh ./proc_sub.sh: line 3: syntax error near unexpected token `(' ./proc_sub.sh: line 3: `cat <(echo hello) <(echo world)' I am currently using the bash for cygwin: GNU bash, version 3.00.16(11)-release (i686-pc-cygwin) Copyright (C) 2004 Free Software Foundation, Inc. |
The clue is:
Code:
#!/bin/sh |
All times are GMT -5. The time now is 10:30 PM. |