我经常在网上看到用不同符号连接各种命令的教程。例如:
command1 | command2
command1 & command2
command1 || command2
command1 && command2
Run Code Online (Sandbox Code Playgroud)
其他人似乎将命令连接到文件:
command1 > file1
command1 >> file1
Run Code Online (Sandbox Code Playgroud)
这些是什么?他们叫什么?他们在做什么?还有更多吗?
我有这个cat
然后sed
操作:
cat ${location_x}/file_1 > ${location_y}/file2
sed -i "s/0/1/g" /${location_y}/file2
Run Code Online (Sandbox Code Playgroud)
这可以在一行中完成吗?
我可能会错过这样的方式在这里,但这个解释在我看来,解决的是相反的,我不能太团结以上cat
,并sed
为一个操作,而双号(&&
)或分号(;
),并越来越接近假设它是不可能的,但在这里问对我来说很重要,因为我可能是错的。
并非所有讲英语的读者都熟悉术语“&符号”或“分号”,因此我详细说明了这些。