我试图写一个短篇的文字,在短文中,我用来搜索一个溪流,然后根据弹道功能的结果,在溪流上进行替代,这就需要争论,比如说。
#!/bin/sh
function test {
echo "running test"
echo $1
}
sed -n -e "s/.*(00).*/$(test)/p" < testfile.txt
试验文件。 注
1234
2345
3006
4567
(每条新线之间有新线;它们正在被贵点清除。) So ok that script work for me (output "running test”),但显然没有经过任何论证。 我愿这样说:
sed -n -e "s/.*(00).*/$(test 1)/p" < testfile.txt
产出:
running test
00
So that the pattern matched by sed is fed as an argument to test. I didn t really expect the above to work, but I have tried every combination of $() brackets, backticks, and escapes I could think of, and can find no mention of this situation anywhere. Help?