This article lists the tail commands in the linux file creation command to teach you how to use the tail command to create a self-decompressed tar file. The Tail command parameter has a parameter-n, -- linesN, which can be directly output by
This article lists the tail commands in the linux file creation command to teach you how to use the tail command to create a self-decompressed tar file.
The Tail command parameter contains the-n, -- lines = N, which can directly output the last N lines in a file.
Using this parameter and the tar command, you can create a windows-like winrar self-decompressed file in linux.
- #! /Bin/sh
- [$ #! = "1"] & echo "Usage: $0 tarfile" & exit 0
- DESTFILE = "$ 1.sh"
- Echo "#! /Bin/sh "> $ DESTFILE
- Echo "LINES = 'WC-l $0 | awk '{print $1}'' "> $ DESTFILE # calculate the number of rows of the target file
- Echo "LINES = 'expr $ LINES-4 '"> $ DESTFILE # Calculate the row to be output, which is the total number of rows-4 (4 rows run the script)
- Echo "tail-n $ LINES $0 | tar-xv" >>$ DESTFILE # output and release (compressed files can be released in combination with-z/-j)
- Echo "exit 0" >>$ DESTFILE
- Chmod + x $ DESTFILE
- Cat $1 >>$ DESTFILE # add the tar file to the end of the file
The above is the usage of the tail command in the linux file creation command.