Linux 19th day sed and compression tools
Time: 20180806
Directory
Compression decompression
Gzip/gunzip/zcat
Bzip/bunzip/bzcat
Xz/unxz/xzcat
Zip/unzip
Tar, Cpio
Sed
Compression decompression
gzip/gunzip. GZ This tool can only be compressed by single file
-# 1-9 Specify compression ratio
-D Decompress decompression
-C Output The original file content to standard output for redirection to back up files, this way backup does not delete the original file
Gzip-c/etc/shadow >/path/file.gz
zcat viewing file contents in. GZ compressed format
bzip2/bunzip2. bz2
-D unzip the. bz2 suffix file
-K do not delete original file compression
-C Output The contents of the file to standard output for redirection compression or decompression without moving the original file
bzcat View contents of the. bz2 file type
xz/unxz compressing or decompressing the XZ file
-D Unzip the XZ compressed file
-K Keep the original file while compressing the file
xzcat View the contents of the XZ file type
zip/unzip Support Compression directory
-R recursive compression, which means that all files in the directory are packaged and compressed into a single file
Tar Archive compression tool
-C Create creates a new archive file
-V Browse the compression process
-f Specifies the file name to archive or the file name to unzip
-X extract Unzip the archive
-C Specify the location of the extracted files
-P archive retains original permissions for files
-R Append the new file to an archive file
-T displays or lists the list of archived files
-j file compression after archiving using BZIP2
-Z files are compressed after archiving using gzip
-J files are compressed after archiving using XZ
-exclude=pattern exclude certain file names in the specified path when archiving
The-t option specifies the input file
-x Specifies the files to exclude
File View types of files
splist file fragmentation to make it easier for future web sites to not allow large file transfers
-b Specifies the size of the single file to split
-d Specifies a number, the file suffix to be split will be a number default to the letter
Merge mode
Cat x* > Original.file
Cpio Archive Compression Tool
> file name or device name
< file name or device name
-O run copy-out mode is standard input and output modes
-o Specifies the file to be archived
-a attach the specified file to an existing archive file
-I extract running copy-in mode reads the archive from the standard input and outputs it to the standard output
-L link files instead of copying them
-T output Content list
-f Specifies the file path of the archive
-d The directory is generated when unpacking, and the directory is created automatically when Cpio is restored
-V Displays the file name during the packaging process
Text Processing tool SED
Sed
sed [OPTION] ... {Script-only-if-no-other-script} [Input-file] ...
-N silent mode, the default is to print each line of the document
-e implements multiple scripts connections similar to GREP-E
-f Specifies a scripts file path
-R using extended regular expressions
-i[.back] Modify the original file, if. Back Plus will change the original file name to *.back before modifying
Script
' Address delimitation '
# given a specific line number $ last line ^ first row
/pattern/rows to which the pattern is matched
#,# line from start # to end #
#,+# + #行 from the beginning #
/patr1/,/patr2/from the first part1 match to the first part2 match to the end of the loop lookup
The first 1 is the starting line, the back 2 steps for how much to achieve parity and even line printing
Edit command
D Delete
P Printing
A [\]text append text to the line that matches to
I [\]text attach file to line before matching to
c [\]text Modify the row to which it is matched
W Save the modified file to the specified file
R reads the specified file to the line to which it is matched
= Displays the line number of the line to which it is matched
! Take counter
s///Find Replacement
G Global Substitution
P shows the row that replaced the successful
W will replace the successful line in the file
\u convert file with uppercase characters
\l Convert file with lowercase characters
s//' VAR '/replace call variable behind
Advanced editing commands for SED
P Print mode space start to \ n content, and append to default output
H overlay the contents of the pattern space into the hold space
H Append the contents of the pattern space to the hold space
G Remove data from the hold space and overlay into the pattern space
G extracting data from the hold space and appending it to the pattern space
X swap the content in the hold with the content in the pattern space
N reads the next line of matching rows to the pattern space
N Append to pattern space for the next line of the row to be read
D Delete rows in the pattern space
D If the pattern space contains a newline character, delete the text in the pattern space until the first line break appears
The new output line is not read, and the loop is restarted using the pattern space of the composition. If the pattern space does not
Contains a newline character, the normal new loop is started as if the D command was issued
ldd View the library file called by the command
Ldconfig Displays the shared libraries currently loaded by the system
-p displays shared library files that are currently loaded into memory by the system
Linux 19th day sed and compression tools