Linux系统命令
which
:查看命令的位置
which cd
find
:查看文件的位置
find 起始路径 -name “查找的文件名”
find 起始路径 -size +|- n [k|M|G]
find / -name test.txt
查找大于100k的文件
find / -size +100K
grep
:从文件中过滤关键字
grep [-n] 关键字 文件路径
-n:可选,表示结果中显示的匹配的行的行号
grep "demo" test.txt
使用管道符"|",下列表示:从test.txt文件中过滤demo字符的位置,管道符表示:将左边内容作为右边的输入
cat test.txt | grep "demo"
wc
数量统计
wc [-c -m -l -w] 文件路径
option | 含义 |
---|---|
-c | 统计bytes数量 |
-m | 统计字符数量 |
-l | 统计行数 |
-w | 统计单词数量 |
wc test.txt
echo
在命令行输出指定内容
echo 输出的内容
echo "hello Linux"
使用“`”以命令形式输出
echo `pwd`
使用">"重定向方法覆盖写入,下列表示:将hello覆盖写入test.txt文件
echo "hello" > test.txt
使用">>"重定向方法追加写入,下列表示:将hello追加写入test.txt文件
echo "hello" >> test.txt
tail
查看文件尾部信息
tail [-f -num] Linux路径
option | 含义 |
---|---|
-f | 持续跟踪 |
-num | 统计字符数量 |
持续跟踪该文件的尾部内容,如果有变化,会更新状态,点击ctrl+c退出程序
tail -f test.txt