cat 显示文件内容
more 翻页,空格下翻。结束自动退出,q退出
more hello.txt
less 翻页,b上翻,空格下翻。结束不自动退出,q退出
less hello.txt
head 默认显示文件内容前10行
head hello.txt
-n 显示前n行 head –n 5 hello.txt 或head -5 hello.txt
tail 默认显示文件内容的最后10行
tail hello.txt
-n 显示最后n行 tail -n 5 hello.txt
管道 管道左侧的输出作为右侧的输入
|
分页,每页10行,第3页
head -30 hello.txt | tail
xargs 管道左侧的输出作为右侧的参数
echo "/" | ls 错误,因为ls不需要输入,只需要参数
echo "/" | xargs ls
重定向
> 覆盖,标准输出重定向
>> 追加,标准输出重定向
2> 覆盖,错误输出重定向
2>> 追加,错误输出重定向
< 将标准输入重定向到文件 cat < hello.txt
<<< 将标准输入重定向到字符串 cat <<<”hello”
网友评论