- Learning Linux Shell Scripting
- Ganesh Naik
- 193字
- 2021-06-25 22:02:49
The cut command
The cut command is used to extract specified columns/characters of a piece of text, which is given as follows:
- -c: Specifies the filtering of characters
- -d: Specifies the delimiter for fields
- -f: Specifies the field number
The following are a few examples that show the usage of the cut command:
- Using the next command, from the /etc/passwd file, fields 1 and 3 will be displayed. The display will contain the login name and user ID. We use the -d: option to specify that the field or columns are separated by a colon (:):
$ cut -d: -f1,3 /etc/passwd
- Using this command, from the /etc/passwd file, the fields 1 to 5 will be displayed. The display will contain the login name, encrypted password, user ID, group ID, and user name:
$ cut -d: -f1-5 /etc/passwd
- This command will show characters 1 to 3 and 8 to 12 from the emp.lst file:
$ cut -c1-3,8-12 /home/student/emp.lst
- The output of the date command is sent as an input to the cut command and only the first three characters are printed on screen, which is shown as follows:
$ date | cut -c1-3 Mon
推薦閱讀
- 輕輕松松自動化測試
- Mastering Spark for Data Science
- 樂高機器人EV3設計指南:創造者的搭建邏輯
- TIBCO Spotfire:A Comprehensive Primer(Second Edition)
- Dreamweaver CS3網頁設計50例
- Mastering Salesforce CRM Administration
- 機艙監測與主機遙控
- Data Wrangling with Python
- 從零開始學SQL Server
- Windows安全指南
- INSTANT Adobe Story Starter
- 軟測之魂
- 渲染王3ds Max三維特效動畫技術
- 人工智能基礎
- Building Analytics Teams