shell_1
放大:sudo apt-get install open-vm-tools
head --help:
输出前多少行:
文件:(比如日志文件)前几行:head -n 7 桌面/p4.py (head -7 桌面/p4.py)
输出前几个字节:
head -c2 桌面/p4.py
tail:
输出后10行:
tail 桌面/p4.py
tail -11 桌面/p4.py(后11行)
查看实时文件(比如实时日志):
tailf 桌面/p4.py
tail -f 桌面/p4.py
vim:
vim student.txt
保存后退出:esc :wq或者esc ZZ
cut:
取第几列(要求分隔符需有规则):
cut -f1 student.txt
取第2-3列:
cut -f2-3 student.txt
取不规则时(-d: 以:分割):
cut -d: -f2-4 etc/passwd
面试题:取文件文件p4.py文件7~9行
答:head -9 桌面/p4.py | tail -3