File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change
1
+ # 1. 在单个命令中创建目录树。mkdir -p
2
+ # 2. 更改路径;不要移动存档。tar xvfz -C
3
+ # 3. 将命令与控制操作符组合使用。&& ||
4
+ # 4. 谨慎引用变量。"$var"
5
+ # 5. 使用转义序列来管理较长的输入。\
6
+ # 6. 在列表中对命令分组。{} ()
7
+ # 7. 在 find 之外使用 xargs。find -print0 | xargs -0
8
+ # 8. 了解何时 grep 应该执行计数——何时应该绕过。grep -c 或 wc -l
9
+ # 9. 匹配输出中的某些字段,而不只是对行进行匹配。awk '$6 == "xxx"'
10
+ # 10. 停止对 cat 使用管道。
11
+
1
12
dd if=text6 conv=ucase ibs=20 obs=30
Original file line number Diff line number Diff line change @@ -7,3 +7,5 @@ xargs < text1 -n1 echo "args>"
7
7
ls t* 1 | tr " \n" " \0" | xargs -0 grep ' 1'
8
8
9
9
# 记住,使用管道导出包含未受保护的空格的内容将导致问题,因此如果您要使用管道将输出导出到xargs,请将 -print0 选项和 find 结合使用,并使用 -0 选项告诉 xargs 接收使用 null 分隔符分隔的输入。其他命令,包括tar,也支持使用 -0 选项并用 null 分隔符分隔的输入,因此应该对支持该选项的命令使用它,除非您能确保您的输入列表不会造成问题。
10
+
11
+ # xargs 可以在需要将文本筛选到单个行中的任何时候使用
You can’t perform that action at this time.
0 commit comments