Linux Useful Commands I'm Unfamiliar with

ls -l filename 列出文件rwx权限
du -h . disk use helper - 列出各个文件大小
ls -ltr list all files by modification time, sorting(t) reverse(r)
/ – search for a pattern which will take you to the next occurrence.
find folder/ -name aaa.txt Find files. You can use regex after -name.
find folder/ -type f Find all files.
find folder/ -type d File all dirs.

用简单的unix command,可以进行一些data processing的工作。这里边的设计哲学,可以看作mapreduce的前身。

awk(=filter and print)
awk '{print $7}' file.txt |  # 将file.txt里的语句分割,并取出第7项
sort | # 排序
uniq -c | # 去重,并打印出每个record的计数
sort -r -n | # 反向排序,其中-n表示以每个record开头的数字来进行排序
head -n 5 # 只输出前五项

awk '{print length($1), $2}' text1.txt # print the len of first and second columns with whitespace as delimiter
$(NF-1) # the second last column
awk `NR==2, NR==5 {print $0}` text1.txt # get the second to fifth row 
awk `NR==2; NR==5 {print $0}` text1.txt # get the second and fifth row 
awk -F ";" '{print $1}' a.txt # change delimiter(field) to ;
awk '$2~/usa|italian/ {print $2, $4}' a.txt # // is regex. $2~ only looks in the second column.
awk '$1==$3 {print}' a.txt # search first and third column the same
sed
grep(=search)
grep -i so a.txt # search for case insensitive occurrences of "so" in a.txt
ls | grep t  # search for all files with word "t"
ls | grep -v t  # search for all files without word "t"
sort
uniq
xargs

Reference:

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 这篇文章翻译自http://www.thegeekstuff.com/2010/11/50-linux-comma...
    sufun_wu阅读 4,155评论 0 4
  • cat cdchmod chowncp cut名称:cat使用权限:所有使用者使用方式:cat [-AbeEnst...
    Creator93阅读 2,948评论 0 0
  • 目录与路径绝对路径与相对路径:略目录的相关操作几个特殊目录. 代表此层目录.. 代表上一层目录- 代表前一个工作目...
    March_13th阅读 3,526评论 1 1
  • 常用操作以及概念 求助 –help 指令的基本用法与选项介绍。 man man 是 manual 的缩写,将指令的...
    Fellers阅读 3,273评论 0 3
  • 1. tar 创建一个新的tar文件 $ tar cvf archive_name.tar dirname/ 解压...
    dazdingos阅读 3,301评论 0 0

友情链接更多精彩内容