using command substitution inside a sed script, with arguments
I am trying to write a short script in which I use sed to search a stream, then perform a substitution on the stream based on the results of a shell function, which requires arguments from sed, e.g. #!/bin/sh function test { echo "running test" echo $1 } sed -n -e "s/.*\(00\).*/$(test)/p" < testfile.txt where testfile.txt contains: 1234 2345 3006 4567 (with newlines between each; they are getting removed by your sites formatting). So ok that script works for me (output "running test"), but obviously has no arguments passed to test. I would like the sed line to be something like: sed -n -e "s/.