> : means overwrite
例:cat /etc/passwd > a.txt echo '123' >> a.txt
>> : append
例:cat /etc/passwd >b.txt echo '123'>>b.txt
Merge multiple files into one file
例:cat a.txt b.txt > c.txt
wc : pipe character
Example: wc -l /etc/passwd to see how many lines there are in the file
cat /etc/passwd | wc -l shows the number of lines
cat /etc/passwd /etc/shadow | wc -l View the total number of lines in the two files
2. Archiving and Archiving Technology (tar)
1) Definition: Arching is the packaging of many files (or directories) into one file
2) Purpose: The purpose of archiving is to facilitate backup, restore and file transfer operations
3) Function: Put multiple files (and possibly directories, because directories themselves are files) together into a tape or disk archive. and in the future as needed
Restore only some specified files in the document
4) Common options of the tar command:
c : create a new tar file
t : list the contents of the directories in the tar file
x: extract files from a tar file
f : specify the archive file or tape (and possibly floppy disk) device (usually selected)
v: Display the detailed information of the packaged file, v is the first letter of verbose.
z: use the gzip compression algorithm to compress the packed file
j: use the bzip2 compression algorithm to compress the packaged file
5) Examples of creating, viewing and extracting archive files:
1) tar cvf testdir.tar testdir # The tar command packs the testdir directory into an archive file named testdir.tar (requires display of all packed files and directories)
2) tar tf testdir.tar # method to display all files in the archive file testdir.tar
3) tar xvf testdir.tar -c path #How to restore all the content in testdir.tar
decompress
tar -xvf file.tar //decompress the tar package
tar -xzvf file.tar.gz // 解压 tar.gz
tar -xjvf file.tar.bz2 // 解压 tar.bz2
tar -xZvf file.tar.Z //decompress tar.Z
unrar e file.rar // depressurar
unzip file.zip //unzip the zip