In csh: How do I redirect the output from a
foreach
-loop to a pipe?
This works but uses a temp file:
set tmpfile=/tmp/file
true > $tmpfile
foreach v (set | awk -e '{print $1}' |grep -v prompt2
);
eval if'($?'$v' && ${#'$v'} > $tmpfile
eval if'($?'$v' && ${#'$v'} > 1) echo array'$v'="$'$v'"' >> $tmpfile
end
cat $tmpfile | parallel --shellquote | perl -pe 's/^scalar(\S+).=/set $1=/ or s/^array(\S+).=(.*)/set $1=($2)/;'
I would like to get rid of the temp file and use a pipe instead. So something like this (does not work):
( foreach v (set | awk -e '{print $1}' |grep -v prompt2
);
eval if'($?'$v' && ${#'$v'} 1) echo array'$v'="$'$v'"'
end ) | parallel --shellquote | perl -pe 's/^scalar(\S+).=/set $1=/ or s/^array(\S+).=(.*)/set $1=($2)/;'
Asked by Ole Tange
(37348 rep)
Oct 4, 2015, 02:32 PM
Last activity: Oct 31, 2023, 08:34 PM
Last activity: Oct 31, 2023, 08:34 PM