Shell
cany1000
积极,向上,努力,踏实。
展开
-
Shell脚本 - cut、sort、paste
1、cut:用来提取文件的片段-d 后面指定分隔的符号-f 指定显示第几列-c 后面跟显示的字符1-n,character-b 后面根据显示的字节,bytekdvmt@kdvmt:temp$ cat 2.txt | cut -b 1-6hello name yleaf ckdvmt@kdvmt:temp$ cat 2.txt | cut -c 1-5helloname leafkdvmt@kdvmt:temp$ cat 2.txt hello dog, hello原创 2021-07-23 17:20:30 · 556 阅读 · 1 评论 -
Shell脚本-NF、FS(OFS)、RS(ORS)、NR(FNR)
NFNF:number of fileds(字段/域的个数)整数$NF: 取最后一列的字符串等同于$1、$2等等来看个例子吧kdvmt@kdvmt:temp$ ls *.sh -al-rwxr-xr-x 1 kdvmt kdvmt 72 2021-07-12 16:27 fileexist.shkdvmt@kdvmt:temp$ ls *.sh -al | awk -F ' ' '{print NF}'8kdvmt@kdvmt:temp$ ls *.sh -al | awk -F ' '原创 2021-07-22 19:51:37 · 4002 阅读 · 0 评论