国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > Linux Shell > 正文

shell字符截取命令之cut命令的實例詳解

2020-07-27 18:51:35
字體:
來源:轉載
供稿:網友

shell字符截取命令之cut命令的實例詳解

一 語法

cut [選項] 文件名選項:-f 列號:提取第幾列-d 分隔符:按照指定分隔符分割列

 二 實戰

[root@localhost ~]# cat student.txt1 furong F 852 fengj F 603 cang F 70[root@localhost ~]# cut -f 2 student.txtfurongfengjcang[root@localhost ~]# cut -f 2,4 student.txtfurong 85fengj 60cang 70[root@localhost ~]# grep "/bin/bash" /etc/passwd|grep -v "root"|cut -f 1 -d ":"cakin24testcls[root@localhost ~]# cut -d ":" -f 1,3 /etc/passwdroot:0bin:1daemon:2adm:3lp:4sync:5shutdown:6halt:7mail:8operator:11games:12ftp:14nobody:99systemd-bus-proxy:999systemd-network:998dbus:81polkitd:997abrt:173unbound:996tss:59colord:995usbmuxd:113geoclue:994rpc:32rtkit:172chrony:993radvd:75qemu:107avahi-autoipd:170setroubleshoot:992rpcuser:29nfsnobody:65534saslauth:991libstoragemgmt:990pulse:171gdm:42gnome-initial-setup:989avahi:70sshd:74postfix:89ntp:38tcpdump:72cakin24:1000test:1003cls:1001

 三 cut命令的局限

df -h|cut -d " " -f 1,3

只能分割比較規則的文本,一般分割符是制表符或冒號。

不能簡單的用空格作為分割符。

如有疑問請留言或者到本站社區交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 长丰县| 凤翔县| 江安县| 台东市| 中阳县| 土默特左旗| 左权县| 蓬安县| 乌拉特后旗| 沂源县| 毕节市| 壶关县| 华宁县| 扎赉特旗| 贵阳市| 宝坻区| 辉南县| 密山市| 平陆县| 兰考县| 辉南县| 天峨县| 阳信县| 宝坻区| 南充市| 吉木萨尔县| 永定县| 陕西省| 车致| 临武县| 平谷区| 漳浦县| 岳池县| 云安县| 尼木县| 郧西县| 孙吴县| 监利县| 镇远县| 赣榆县| 潼南县|