hi,
how can i make use of a command in the replacement segment..
cat a | sed '/^[[:digit:]]\{3\}$/{
s/\(.\)/REPLACEMENT/g
}'
suppose if I want to use a awk command in the replacement section , how to achieve that ?
Thanks
hi,
how can i make use of a command in the replacement segment..
cat a | sed '/^[[:digit:]]\{3\}$/{
s/\(.\)/REPLACEMENT/g
}'
suppose if I want to use a awk command in the replacement section , how to achieve that ?
Thanks
Use backticks, double quotes and remove cat command (is useless):
sed "/^[[:digit:]*]\{3\}$/{
s/\(.*\)/`awk '{ blah blah blah }' awk_input_file.txt`/g
}" a
But I highly recommend to put the awk result into a variable and pass that variable in sed script, especially if the awk code is complex:
VAR=`awk '{ blah blah blah }' awk_input_file.txt`
sed "/^ ... $/s/.*/${VAR}/g" sed_input_file.txt