我想做的是:
>STRIPPER='sed s/admin_editable=\"[01]\"// | sed s/runtime_editable=\"[01]\"//'
>cat file.txt | $STRIPPER > stripped.txt
即定义一个shell变量,它是多个命令的管道(我的恰好是sed
's),然后我可以稍后调用。我现在从命令行执行此操作,但最终可能会将其放入脚本中。
我已经尝试了 ' 和 " 来包含命令都不起作用。
sed: can't read |: No such file or directory
sed: can't read sed: No such file or directory
sed: can't read s/admin_editable=\"[01]\"//: No such file or directory
sed: can't read |sed: No such file or directory
sed: can't read s/runtime_editable=\"[01]\"//: No such file or directory
sed: can't read |: No such file or directory
我知道可能有一个正则表达式可以处理这种情况,但我想知道如何做一般的管道。