3. Basic Commands-2
Basic Commands-2
Compression and archiving
Pack: Archive, similar to pack before travel
Compression: To reduce the amount of disk space used, backup can be done to save network bandwidth when transferring over the network.
Packaged compression software
Windows:winrar 360 compression Good 7zip WinZip
Linux: Compact format: GZ, bz2,xz,zip,z compression algorithm, resulting in different compression ratios
Compression software gzip bzip2 xz zip software that can be packaged and compressed: Tar *
One, zip:
Compressed files generally end in. zip, you can compress the syntax of the directory
Compression: Zip filename.zip file1 file2 ...
Zip compressed file name compressed files
does not delete the original file
for example [[[email protected] acltest]# zip com.zip com.txt
Adding:com.txt ( Deflated 99%)
Decompression: Unzip
-D: Specify the decompression path
II, gzip
1) gzip/path/to/somefile default Delete original file
-D extract
-#: Specify compression ratio, smaller compression ratio , the greater the Speed
2) gunzip/path/to/some_compress_file
3) zcat some_compress_file to view the compressed file of the text
Example: #cp/var/log/ Messages./
gzip messages default suffix name:. GZ
Gzip compression, the original file disappears, generate a compressed file
Extract: Gunzip
Gzip Compressed package, after decompression, the compressed package disappears, the extracted file appears.
compression is actually level: the 1~9 1 is the lowest, the fastest, the least efficient, 9 is the highest, the slowest, and the most efficient. The
Default level is 6.
Three, bzip2 by default, the compression is complete,
The original file is also disappeared, the compressed package must end in. bz2
can usually generate smaller files than using gzip compression (high compression)
1) bzip2/path/to/somefile
-D: Decompression
-#: Specify compression ratio
-K: Keep the original file
2) bunzip2/path/to/somefile
3) bzcat/path/to/some_compress_file no pressure view
Decompression: BUNZIP2 four. XZ Compression ratio greater
1) compression XZ somefile
2) decompression
Unxz or Xzdec
-D: Decompression
-K: Keep the original file
-C: Input to screen
3) Xzcat No pressure view
format of compressed packages that are common later
. zip. tar.gz. tar.bz2
v. Tar Can be packaged and compressed
Tar option package name package file or directory//remember: Be sure to pay attention to the syntax format, first the packaged name, and then the stuff to pack.
Tar: Archive tool,. Tar For example: TAR-CF
-C: Create an archive file
-F File.tar: Archived files for operations
-X: Expand Archive
--xattrs: Preserves extended attribute information for files when archiving
-T: Do not expand the archive to directly see which files are archived
-C: Specify the path when extracting
-r: Append files to the package
-P: Retain permission information
-V: Show detailed procedures
-ZCF: Archive and invoke gzip compression
-ZXF: Call gzip to unzip and expand Archive,-Z option to omit
-jcf:bzip2
-JXF:
-jcf:xz
-JXF:
1) packaging compression at the same time
-Z: Compressed or uncompressed using gzip compression
-j: Indicates compression or decompression using BZIP2 compression
-C: Represents the creation of--create
-V: Show detailed procedures
-F: Specify file, typically followed by parking name
-ZCVF ZCVF. tar.gz
-JCVF JCVF. tar.bz2
Tar zcvf com.tar.gz com.txt
Com.txt
ll
Total 67968
-rw-r--r--1 root root 367957 Jul 09:24 com.tar.gz
Tar zcvf/tmp/acltest.tar.gz/acltest/
2) unpacking. tar.gz. tar.bz2
-ZXVF ZXVF
-JXVF JXVF
-C: Specify the decompression path
Tar zxvf com.tar.gz-c/usr/local/src/ls/usr/local/src/
Com.txt Vmware-tools-distrib
3) Other options
-T: Do not understand the contents of the Package view package
Tar-tf/tmp/acltest.tar.gz
acltest/
Acltest/f1
Acltest/com.txt
Acltest/f3
Acltest/f2
Acltest/com.zip
Acltest/com.tar.gz
-r: Append file to package, cannot append compressed file
TAR-RF file appended with package name
Three. File Search
Which: the absolute path used to find the command
--Show the absolute path of the shell command
--Simply search for the command you want to find in the PATH variable
--Search for aliases, then find them from path
1. View the user's path variable: The search path for the command
Echo $PATH/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/root/bincommand Not found possible causes:
1) The Wrong knock
2) command not installed
3) The path of the command is not in the definition of the PATH variable CP
which vim
/tmp/vim2vim2/etc/passwd
Bash:vim2:command not found
/TMP/VIM2/ETC/PASSWD//absolute path execution
2. Add paths to Path
1) temporarily modify the path value
Path= $PATH:/tmp//$PATH: Retain variable original value echo $PATH
/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/root/bin:/tmp
2) permanently modify the path value will always be used in the work
/etc/profile//Global profile, effective for all users
~username/.bash_profile//local profile, only valid for specific users
Vim/root/.bash_profile
Path= $PATH: $HOME/bin:/tmp The above file is not in immediate effect, it is normally executed when the user logs on.
Source/root/.bash_profile//re-read the configuration file so that the changes take effect echo $PATH
/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/root/bin:/root/bin:/tmp
Cons: Every time a new terminal or a tag, need to execute # source/root/.bash_profile if you want to once and for all, then need to exit the system, re-login, that is, logout.
system--> Log out root--> log out
Echo $PATH/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/root/bin:/ Tmpwhich ls
Alias ls= ' ls--color=auto '
/bin/ls
which vim
Alias for/usr/bin/vim Command: Alias
1. See what aliases are present on the system (root and normal user aliases may be different)
Alias
2. Set the alias of the command
1) Temporary
Alias vi= ' vim ' vi/etc/passwd//execute VI when actually performing VIM
2) Permanent, change file
(1)/ROOT/.BASHRC CP RM MV (2)/ETC/PROFILE.D
colorls.sh
which2.sh
3. Cancel Aliases
[profile.d]# Unalias VI
[profile.d]# vi/etc/passwd//No color anymore
Locate
--Retrieve files by file name with the fastest retrieval speed
--all the things that can be retrieved are stored in the database.
-Locate limitations, some file systems, some files and some directories are not searched by default
1, suppose I know the name of the NIC configuration file, but do not know the specific path:
Locate Ifcfg-eth0
/etc/sysconfig/network-scripts/ifcfg-eth0
Locate Ifcfg
/etc/dbus-1/system.d/nm-ifcfg-rh.conf
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/sysconfig/network-scripts/ifcfg-lo
/sbin/ifcfg
/usr/lib64/networkmanager/libnm-settings-plugin-ifcfg-rh.so
/usr/share/man/man8/ifcfg.8.gz
/var/log/anaconda.ifcfg.log
2. Manually update the database
Cp
which vim
/root/vim3locate VIM3//No results found
Cause: Because the locate database is a one-day update, it is not updated in real time.
Updatedblocate vim3
/ROOT/VIM3 database file:/var/lib/mlocate/mlocate.db
----------------------------------------------------------Error:
1) database file does not exist
2) manually generate it
UpdateDB
3. Locate database configuration file
Vim/etc/updatedb.confls/tmp/vim2
/tmp/vim2
Locate VIM2//cannot be searched because/tmp is in the exclusion list
Find * * * *
--Global search file
--How to work: Search down the hierarchy of files, find eligible, print, or perform the appropriate actions
First, the syntax format
Find to search for path conditions (options) [Action]
1. Basic examples
find/etc/-name Network
/etc/vmware-tools/scripts/vmware/network
/etc/sysconfig/network
/etc/rc.d/init.d/network in general, the larger the lookup range, the deeper the directory level, and the slower the lookup speed.
Mkdir-p/q/w/e/r/t/y/u/i/o/p/a/s/d/f/g/h/j/k/l/z/x/c/v/b/n/mtouch/q/w/e/r/t/y/u/i/o/p/a/s/d/f/g/h/j/k/l/z/x/c/v /b/n/m/test.txttime Find/-name test.txt
/q/w/e/r/t/y/u/i/o/p/a/s/d/f/g/h/j/k/l/z/x/c/v/b/n/m/test.txt
/acl/test.txt
/tmp/test.txt
Real 0m3.188s
User 0m0.061s
SYS 0m2.953s Exercise:
Find files with the name config in the/etc directory
Find/etc-name Config
/etc/vmware-tools/config
/etc/selinux/config
2. Search by condition
1) Search by file name
-name: Search by name * * * *
-iname: Ignoring case
Find/etc-name Networkmanagerfind/etc-iname NetworkManager
/etc/rc.d/init.d/networkmanager
/etc/networkmanager
Wildcard: * represents any character
? Represents a single character
Find all files ending with. conf in the/etc directory
find/etc/-name *.conf Find the/etc/directory, ending with. conf, with a name of 5 characters
find/etc/-name "?????. Conf "Exercise:
Find files with the name ntp.conf under the/etc directory
Find/etc-name ntp.conf
/etc/ntp.conf Find/directory, file with name passwd
Find/-name passwd
2) Find-type by file type
F: Normal file
b c D l s P
Find/var-type L//Find the var directory under type is soft-linked file ll
find /var -type l
Verify that all found are soft links find/tmp/-type F
-type can only be followed by one letter.
-----------------------Exercise: Find files in your system that are type sockets
Find/-type s when looking, may encounter no such file or directory error, is normal, if you do not want to see can redirect the error to "Black Hole" (/dev/null) Find/-type s 2>/dev/null
3) Search by Time (written question)
-atime N in days
-ctime N
-mtime N
-amin N in minutes
-cmin N
-mmin N
N is a number and can be preceded by + or--mtime n
+n:n+1 days ago
N # to N+1 days
Within-n:n days
Take n equals 7 for example:
Search for all files that have been visited in the last seven days
Find. -type f-atime-7 Search All files that were visited exactly seven days ago
Find. -type f-atime 7 Search All files that have been accessed in more than seven days
Find. -type f-atime +7 Search for all files with access time exceeding 10 minutes
Find. -type f-amin +10 Find all files that are longer than the File.log modification time
Find. -type F-newer File.log
----------------------------------------------------------------------episode:
View property information for a file? Stat file name
Stat passwd
File: ' passwd '
size:1030 blocks:8 IO block:4096 Regular file
device:802h/2050d inode:917613 links:1
Access: (0644/-rw-r--r--) Uid: (0/root) Gid: (0/root)
access:2015-08-08 20:38:22.080984537 +0800 modify:2015-08-08 20:38:22.080984537 +0800
change:2015-08-08 20:38:22.080984537 + 8,001 files have three times:
Atime: Access time, cat more less ...
Mtime: The content of the file changes in time vim ... (also the time shown by LL)
CTime: The time when the properties of a file change, such as: Change of permissions, size change, owner, owning group, etc.
Example:
echo Hello > Filestat file
File: ' File '
Size:6 blocks:8 IO block:4096 Regular file
device:802h/2050d inode:917619 links:1
Access: (0644/-rw-r--r--) Uid: (0/root) Gid: (0/root)
ACCESS:2015-08-13 12:16:19.494018488 +0800 modify:2015-08-13 12:16:19.495018470 +0800
CHANGE:2015-08-13 12:16:19.495018470 +0800
Cat file
Hello
Stat file
File: ' File '
Size:6 blocks:8 IO block:4096 Regular file
device:802h/2050d inode:917619 links:1
Access: (0644/-rw-r--r--) Uid: (0/root) Gid: (0/root)
ACCESS:2015-08-13 12:17:32.381018468 +0800 modify:2015-08-13 12:16:19.495018470 +0800
CHANGE:2015-08-13 12:16:19.495018470 +0800
chmod +x filestat File
File: ' File '
Size:6 blocks:8 IO block:4096 Regular file
device:802h/2050d inode:1197781 links:1
Access: (0755/-rwxr-xr-x) Uid: (0/root) Gid: (0/root)
ACCESS:2015-08-13 12:17:32.381018468 +0800 modify:2015-08-13 12:16:19.495018470 +0800
CHANGE:2015-08-13 12:21:55.563018148 +0800//ctime changes
echo hahaha >> filestat file
File: ' File '
Size:13 blocks:8 IO block:4096 Regular file
device:802h/2050d inode:1197781 links:1
Access: (0755/-rwxr-xr-x) Uid: (0/root) Gid: (0/root)
ACCESS:2015-08-13 12:17:32.381018468 +0800 modify:2015-08-13 12:23:54.286017831 +0800
CHANGE:2015-08-13 12:23:54.286017831 + 0800 Questions
1. Digital permission to print files
Stat-c%a File
755
2, print the letter of the file permissions
Stat-c%A File
-rwxr-xr-x
----------------------------------------------------------------------find small examples by time
Mkdir/finddate
Thu 14:22:43 CST 2015
cd/find/
[find]# touch-t 08131425.30 f0813//-t: Specifies the creation time of the file Mmddhhmm.ss
[find]# touch-t 08121425.50 f0812
[find]# touch-t 08111426.30 f0811
[find]# touch-t 08101426.30 f0810
[find]# ll f*
-rw-r--r--1 root root 0 14:26 f0810
-rw-r--r--1 root root 0 14:26 f0811
-rw-r--r--1 root root 0 14:25 f0812
-rw-r--r--1 root root 0 14:25 f0813
--Find files that have been modified within 24 hours (1 days) under/find
[find]# Find. -mtime-1
.
./f0813
--Find the normal file under/find modified 2 days ago
[find]# Find. -type F-mtime +1
./f0810
./f0811
4) Search by user and group
-user User Name
-group Group Name
-uid UID
-gid GID
-nouser: Orphan file without owner's file
-nogroup: No files belonging to group
--Find files in the system where the owner is QUOTA2
[home]# Find/-user quota2-type F
[home]# Find/-user quota2-type f 2>/dev/null
--Find orphan files in the system
[home]# Userdel Quota2
[home]# Find. -type F-nouser
./quota2/.bash_history
./QUOTA2/.BASHRC
./quota2/.bash_profile
./quota2/.bash_logout
[home]# LLfind . -type f -nouser
-RW-------1 502 quota2 10:16./quota2/.bash_history
-rw-r--r--1 502 quota2./quota2/.bash_logout
-rw-r--r--1 502 quota2 176./quota2/.bash_profile
-rw-r--r--1 502 quota2 124./QUOTA2/.BASHRC
--Find the system owner is not the root of ordinary files! or-not.
[home]# Find/! -user Root-type F or-or or-O
--Find files in the system where the owner is not root or the type is a socket
[home]# Find/! -user Root-o-type S
5) Follow the permissions to find-perm
+222 or (user writable or group writable or other person writable) there are 1 locations in the binary, as long as one of these bits is satisfied
-222 and (User writable and group writable and other people can write) 1 of the binary must have 1
Rm-f/find/*cd/find/
[Find]# Touch p{r,w,x}_{1,2,3}
[find]# chmod pr_1
[find]# chmod pr_2
[find]# chmod 444 pr_3
[find]# chmod pw_1
[find]# chmod pw_2
[find]# chmod 222 Pw_3
[find]# chmod px_1
[find]# chmod px_2
[find]# chmod 111 Px_3
[find]# LLfind ./ -perm +020 -type f
--w--w----1 root root 0 15:13./pw_2
--w--w--w-1 root root 0 15:13./pw_3
[find]# LLfind ./ -perm -020 -type f
--w--w----1 root root 0 15:13./pw_2
--w--w--w-1 root root 0 15:13./pw_3 when the permission bit is only one bit, + and-are the same.
[find]# LLfind ./ -perm -222 -type f
--w--w--w-1 root root 0 15:13./pw_3
[find]# LLfind ./ -perm +222 -type f
--w-------1 root root 0 15:13./pw_1
--w--w----1 root root 0 15:13./pw_2
--w--w--w-1 root root 0 15:13./pw_3 think: Find files in your system that have SUID permissions
6) Find-size by file size
- Greater than
- Less than
Direct number equals
' B ' for 512-byte blocks (the "the default if no suffix is used)//0.5kb
' C ' for bytes
' W ' for two-byte words
' K ' for kilobytes (units of 1024x768 bytes)
' M ' for megabytes (units of 1048576 bytes)
' G ' for gigabytes (units of 1073741824 bytes)
[find]# rm-f/find/*
[find]# DD If=/dev/zero of=f1m bs=1m count=1
[find]# DD If=/dev/zero of=f2m bs=1m count=2
[find]# DD If=/dev/zero of=f3m bs=1m count=3
[find]# DD If=/dev/zero of=f4m bs=1m count=4
[find]# Find. -type f-size-3m
./f2m
./f1m
[find]# Find. -type f-size 3M
./f3m
[find]# Find. -type f-size +3m
./f4m
3. Action
-exec action--perform the action directly after finding the result
-ok action--prompt before performing an action, i.e. interaction required
[find]# Find. -type f-size +3m-exec ls-l {} \;
-rw-r--r--1 root root 4194304 15:51./f4m
{}--used instead of found results
\; --Indicates the end flag
[find]# Find. -type f-size +3m-ok ls-l {} \;
< LS .... /f4m >? Y
-rw-r--r--1 root root 4194304 15:51./f4m
[find]# Find. -type f-size +3m-ok ls-l {} \;
< LS .... /f4m >? N Exercises:
1, find the/find directory, type is a normal file file to move it to the/test directory
[find]# Find. -type f-exec mv {}/test \;
[find]# ls/test/
f1m f2m f3m f4m or
[find]# MVfind . -type f
/test
2, to find the/test directory type is a normal file files, to back up, backup files with the suffix named. bak
[find]# Find/test-type f-exec cp {} {}.bak \;
[find]# ls/test/
f1m f1m.bak f2m f2m.bak f3m f3m.bak f4m F4m.bak
3, delete the/test directory under the modified time within one day of ordinary files
[find]# find/test/-type f-mtime-1-exec rm {} \;
grep text filtering
I. GREP: The goal is to filter out what users are interested in * * *
Syntax: grep [options] mode or keyword file list
Simple example:
[Loring ~]# grep root/etc/passwd
Root:x:0:0:root:/root:/bin/bash
Operator:x:11:0:operator:/root:/sbin/nologin
1 、--color shows the match to the keyword
[Loring ~]# grep--color root/etc/passwd
Root:x:0:0:root:/root:/bin/bash
Operator:x:11:0:operator:/root:/sbin/nologin
2.-I ignores case
[Loring tmp]# grep--color-i root/find/passwd
Root:x:0:0:root:/root:/bin/bash
Operator:x:11:0:operator:/root:/sbin/nologin
3,-V take the reverse
Filter out rows that do not contain nologin
[Loring tmp]# Grep-v NOLOGIN/ETC/PASSWD
4. ^ Start with a keyword
Display non-commented lines in the/ROOT/.BASHRC file
[Loring tmp]# Grep-v ^#/ROOT/.BASHRC
5, $ with a keyword end
Display lines ending in sh in the passwd file
[Loring tmp]# grep sh$/etc/passwd
6, ^$ empty line
Show non-commented lines and non-blank lines in the/ROOT/.BASHRC file
[Loring tmp]# grep-v ^#/ROOT/.BASHRC | Grep-v ^$
7,-c count, count the number of rows to match
[Loring tmp]# Grep-c ROOT/ETC/PASSWD
2
8,-L general and-R are used to display only the name of the file containing the keyword, instead of displaying the contents of the file
9.-R Recursive retrieval
Displays the file name that contains the root in the contents of the test directory
[Loring tmp]# Grep-rl Root/test
10,-Q quiet Silent output is generally used when writing scripts
[Loring tmp]# Grep-q ROOT/ETC/PASSWD
[Loring tmp]# echo $? $? Represents the execution result of the previous command
0 Returns a result of 0: Indicates successful execution of the previous command
Return result not 0: Indicates that the previous command failed to execute
[Loring tmp]# Grep-q JSJDJJDFHFH/ETC/PASSWD
[Loring tmp]# echo $?
1
[Loring tmp]# Grep-q Root/asdaf
grep:/asdaf:no such file or directory
[Loring tmp]# echo $? File does not exist return 2
2
11,-n Displays the line number of the matching row
[Loring tmp]# Grep-n ROOT/ETC/PASSWD
1:root:x:0:0:root:/root:/bin/bash
11:operator:x:11:0:operator:/root:/sbin/nologin
grep Exercises:
1. Display the line containing root in the/etc/group file
[Loring test]# grep Root/etc/group
2. Display lines in the/etc/passwd file that begin with the RP
[Loring test]# grep ^rp/etc/passwd
3. Display the line in the/etc/group file that does not end with:
[Loring test]# grep-v: $/etc/group
4. Display blank line in/etc/rc.local file, require line number
[Loring test]# Grep-n ^$/etc/rc.local
6:
5. Display only files of the file type directory in the/mnt/cdrom directory (provided that the disc is mounted and no find is used)
[Loring test]# ll/mnt/cdrom/| grep ^d Second, cut: is the meaning of interception, its processing object is "one line" text, you can choose the part that users need, do not affect the original file
You can specify a delimiter, and then print out a specific column or columns separated by a delimiter
Syntax: cut-f specified column-d ' delimiter '
-D: Specify the field delimiter
-F: Specifies the area to output, separated by commas
-C: Specify the character of the column
Displays the user name and UID fields in the/etc/passwd file
[Loring test]# cut-d:-f1,3/etc/passwd
[Loring test]# head-5/etc/passwd | Cut-d:-f1,3
root:0
Bin:1
Daemon:2
Adm:3
Lp:4
[Loring test]# head-5/etc/passwd > T1
[Loring test]# Vim T1
:%s/://g
[Loring test]# Cat T1
Root x 0 0 Root/root/bin/bash
Bin x 1 1 bin/bin/sbin/nologin
Daemon x 2 2 Daemon/sbin/sbin/nologin
ADM x 3 4 Adm/var/adm/sbin/nologin
LP x 4 7 Lp/var/spool/lpd/sbin/nologin The first field, separated by a space
[Loring test]# cut-d ""-f1 T1
Root
Bin
Daemon
Adm
Lp
Remove a field from the group name in the/etc/group file
Cut-d:-f1/etc/group Prints the 第1-5个 characters of each line in the/etc/passwd file, as well as the contents of 第7-10个 characters
[Email protected] test]# CAT/ETC/PASSWD | Cut-c 1-5,7-10
Third, sort sorts
-T: Specify field Delimiter
-K: Specify the first few fields
-N: Sort by numerical order
-R: Reverse Sort Reverse
-U: Repeat lines only print once unique
[email protected] test]# cat Sort.txt
B:3
C:2
A:4
E:5
D:1
F:11 sorts the output directly, by default, by the first character of each line
[email protected] test]# Cat Sort.txt | Sort
A:4
B:3
C:2
D:1
E:5
F:11 to reverse-sort output content
[email protected] test]# Cat Sort.txt | Sort-r
F:11
E:5
D:1
C:2
B:3
A:4 use ":" To do a delimiter to sort the 2nd field
[email protected] test]# Cat Sort.txt | Sort-t ":"-K 2
D:1
F:11
C:2
B:3
A:4
E:5 use ":" To make a delimiter, sort the 2nd field, sort by number size
[email protected] test]# Cat Sort.txt | Sort-t ":"-K 2-n
D:1
C:2
B:3
A:4
E:5
F:11 sorting/etc/passwd files by uid
[Loring test]# Sort-t ":"-K 3-n/etc/passwd
Sort the passwd files in the order of the UID from large to small
[Loring test]# Sort-t ":"-K 3-nr/etc/passwd
Print/etc/group in order of GID from small to large
[Loring test]# sort-t:-K 3-n/etc/group
Four, uniq to heavy, the only
Remove adjacent duplicate rows
-C: Shows the number of duplicate rows
-I: Ignore case
[Loring test]# Uniq Num.txt
111
222
333
444
222
555 when using Uniq, the general first sort, then go to heavy
[Loring test]# Sort Num.txt | Uniq
111
222
333
444
555
[Loring test]# Sort Num.txt | Uniq-c
1 111
3 222
2 333
1 444
1 5,555, the main role of TR is text conversion or deletion.
Convert lowercase letters in/etc/passwd files to uppercase
[Email protected] test]# CAT/ETC/PASSWD | TR ' [A-z] ' [A-z] ' remove the ': ' From the/etc/passwd file
[Email protected] test]# CAT/ETC/PASSWD | Tr-d ":" Six, paste text merge. Merge the files into rows, using the tab-separated in the middle.
[email protected] test]# cat A.txt
1
2
3
4
5
[email protected] test]# cat B.txt
A
B
C
D
e merge files by line
[email protected] test]# paste A.txt b.txt
1 A
2 b
3 C
4 D
5 E can also use-D to specify the delimiter between rows of a merged file
[Email protected] test]# Paste-d:a.txt b.txt
1:a
2:b
3:c
4:d
5:e
[Email protected] test]#
Practice:
There are several shells in the statistics/etc/passwd file and show how many users each shell has
[Loring test]# cut-d:-f7/etc/passwd | Sort | Uniq-c
Linux Basic Command Summary (ii)