Sometimes we often encounter problems such as having a page number and a regular, regular name, home address, phone number, notes, etc. We only want to take out the names of everyone and their corresponding phone numbers. How many ways can you do this?
It is true that this vertical positioning method is difficult to implement in the conventional way. At this time, cut can be used. It is.
What’s cut?
Child: The cut command extracts text columns from a text file or text stream.
Command Usage:
cut -b list [-n] [file ...]
cut -c list [file ...]
cut -f list [-d delim][-s][file ...]
Parameters:
-b, --bytes=LIST
Output these Bytes
-c, --characters=LIST
Output these characters
-d, --delimiter=DELIM
Use DELIM instead of TAB Field separator
-f, --fields=LIST
Output these fields
-n
(ignore)
-s, --only-delimited
Do not display rows without separators
--output-delimiter=STRING
Use STRING as output separator, missing (output separator) is the input separator
--help
Display help information, then end
--version
Display version information , then end
using and only use one of -b, -c or -f. LIST is separated by a range or comma The range is composed. The range is one of the following forms:
N
The Nth byte, character or field, starting from 1 count
N-
From Nth byte, character or field up to end of line
NM
From Nth to Mth (and including Mth byte), character or field
-M
From 1st to the Mth (and including the Mth) bytes, characters or fields
If the file FILE is not specified, or FILE is -, it is from the standard Enter the read data.
Example:
The code is as follows:
[root@localhost ~]# cat /etc/passwd |
Cut -b 1 |
Head -5 # Output the first byte of the file
r
b
d
a
l
The code is as follows:
[root@localhost ~]# cat /etc/passwd |
Cut -c 1-4 |
Head -5 # Output the first four characters of the file
root
bin:
daem
adm:
lp:x
The code is as follows:
[root@localhost ~]# cat /etc/passwd |
Cut -f1 -d ':' |
Head -5 #:: split the file, output the first field
root
bin
daemon
adm
lp< Br>
The code is as follows:
# cat a.txt
ssss affff dddd fe fsc
rrr f adfa eer ddd
The code is as follows:
# cat a.txt |
Cut -f1,3 -d $'\\t' #1,3 columns
ssss dddd
rrr adfa
What is a process? A process is a running instance of an already launched executable. The process ha
A. Static library concept 1. A library is a collection of pre-compiled object files that can be lin
1, need to upload or download, you need to use the rz and sz commands. If you do not have th
Command Introduction Shutdown, poweroff, reboot, halt, init can be shut down, approximate
Linux system administrator must-have tool series vmstat
Using forever to implement Node.js project on Linux
Linux compiles the kernel and adds system calls
Linux virtual machine three networking modes and remote login management
Linux installation using jprofiler8 (tomcat)
File descriptors in server programming
Exit command--Linux command application big dictionary 729 command interpretation
Linux system how to create a scheduled task with crontab
Windows 2000 system ping nowhere cache is in trouble
Remove windows7 extra boot menu
Msvdm.dll Microsoft Virtual Desktop
Win8.1 app store can not download and update the app how to do
Solve the problem of Control Panel disappearing in Win 8
Counting six major defects in Win7 xp mode
Win10 system closes the search page when the content prompts the tutorial
Win8.1 Quick Get Win10 Push Method
How to use the undo delete menu in the win7 system right click on the desktop?