[Private manual] Linux Command __linux

Source: Internet
Author: User
Tags bz2 gz file rar
Tar
[Root@linux ~]# tar [-cxtzjvfppn] files and directories ....

Simple to say:

Compress

TAR-CVF Jpg.tar *.jpg//pack all JPG files in the directory into tar.jpg 

tar-czf jpg.tar.gz *.jpg   // After packaging all the JPG files in the directory into Jpg.tar and using gzip compression, generate a gzip-compressed package named jpg.tar.gz

 TAR-CJF jpg.tar.bz2 *.jpg/ After packaging all the JPG files in the directory into Jpg.tar and compressing them with bzip2, generate a bzip2 compressed package named jpg.tar.bz2 tar-czf jpg.tar.z *.jpg   / After packing all the JPG files in the directory into Jpg.tar, and compressing them with compress, it generates a umcompress compressed package, named Jpg.tar.z

rar a jpg.rar *.jpg//rar format compression, Need to download

the RAR for Linux zip jpg.zip *.jpg//zip format compression, first download zip for Linux

Decompression

TAR-XVF File.tar//Decompression tar packets
TAR-XZVF file.tar.gz//decompression tar.gz
TAR-XJVF file.tar.bz2   //decompression tar.bz2
tar -XZVF File.tar.z   //extract tar. Z
unrar e file.rar/decompression rar
unzip file.zip//Unzip zip

Summarize:

1, *.tar with TAR-XVF decompression
2, *.gz with gzip-d or Gunzip decompression
3, *.tar.gz and *.tgz with TAR-XZF decompression
4, *.bz2 with bzip2-d or with BUNZIP2 Decompression
5, *.tar.bz2 with TAR-XJF decompression
6, *. Z with uncompress decompression
7, *.tar. Z with TAR-XZF decompression
8, *.rar with Unrar e decompression
9, *.zip with unzip decompression

Detailed parameters:

-C: Create a compressed file parameter instructions (create);-
x: Unlock a parameter instruction for a compressed file. -
t: View the files inside the tarfile.

in particular, it is noted that c/x/t can only exist in the release of a parameter. Cannot exist at the same time.
because it is not possible to compress and decompress at the same time. -

Z: Whether to have gzip properties at the same time. That is, whether you need to use gzip compression.
-j: Whether to have bzip2 properties at the same time. That is to use bzip2 compression. -
V: Displays files during compression. This is commonly used, but is not recommended for use in background execution processes. -
F: Use file name, please note that after F to immediately pick up the file name Oh. Don't add any more parameters.   
For example, the use of "TAR-ZCVFP tfile sfile" is the wrong way to write
"TAR-ZCVPF tfile sfile" is right. -
P: Use original properties of the original file (properties are not changed according to the consumer)-
p: You can compress using an absolute path. -
N: Newer than the following date (YYYY/MM/DD) will be packaged into the newly created file.
--exclude file: Do not package file in the process of compression.

Example:
Example one: Package all the files in the/etc directory into a/tmp/etc.tar

[Root@linux ~]# tar-cvf/tmp/etc.tar/etc <== packaged only, not compressed.
[Root@linux ~]# tar-zcvf/tmp/etc.tar.gz/etc <== packaged, gzip compressed
[Root@linux ~]# tar-jcvf/tmp/etc.tar.bz2/etc <== packaged to bzip2 compression
# Note that the file name after the parameter F is taken by itself, and we are accustomed to using. Tar as a recognition.
# If you add the z parameter, you can use. tar.gz or. tgz to represent the gzip-compressed tar file ~
# If the J parameter is added, then the. tar.bz2 as the file name ~
# The above instructions, when executed, will display a warning message:
# "tar:removing leading '/' from member names" That's a special set of absolute paths.

Example two: Refer to the documents in the above/tmp/etc.tar.gz document.

[Root@linux ~]# tar-ztvf/tmp/etc.tar.gz
# because we use gzip compression, so when we look at the files in the tar file, we have to
add the z parameter. It's very important.

Example three: Unzip the/tmp/etc.tar.gz file under/USR/LOCAL/SRC

[Root@linux ~]# cd/usr/local/src
[root@linux src]# tar-zxvf/tmp/etc.tar.gz
# in the case of a preset, we can undo the compression file anywhere. In this example,
# I first transform the working directory underneath the/USR/LOCAL/SRC, and unlock the/tmp/etc.tar.gz,
# The catalog will be unlocked in/usr/local/src/etc. In addition, if you enter/usr/local/src/etc
# You will find that the file properties in this directory may be different from the/etc/.

Example four: under/tmp, I just want to untie the etc/passwd in the/tmp/etc.tar.gz.

[Root@linux ~]# cd/tmp
[root@linux tmp]# tar-zxvf/tmp/etc.tar.gz etc/passwd
# I can check the file name in TAR-ZTVF through Tarfile Said, if only one file,
# can be issued in this way. noticed that. The root directory within the etc.tar.gz/was taken away.

Example five: Back up all the files in the/etc/and save their permissions.

[Root@linux ~]# tar-zxvpf/tmp/etc.tar.gz/etc
# This attribute is important, especially if you want to preserve the properties of the original file.

Example six: In/home, a new file is backed up in 2005/06/01

[Root@linux ~]# tar-n ' 2005/06/01 '-ZCVF home.tar.gz/home

Example seven: I want to back up/home,/etc, but don't/home/dmtsai

[Root@linux ~]# tar--exclude/home/dmtsai-zcvf myfile.tar.gz/home/*/etc

Example eight: The/etc/is packaged and unpacked directly underneath/TMP without producing a file.

[Root@linux ~]# cd/tmp
[root@linux tmp]# tar-cvf-/etc | tar-xvf-
# This action is a bit like cp-r/etc/tmp ~ still has its purpose.
# The place to notice in the output file becomes-and the input file becomes-, and there is a | exist ~
# This represents standard output, standard input and Pipeline command.
# This Part we'll talk about this instruction again when we Bash the shell.
Jot

Installation: sudo apt-get install Athena-jot
Command:

Jot:jot-print sequential or random data
usage:  jot [Options] [Reps [begin [end [S]]]]
Options:
  -r      Random Data # random number-
    c      character data #-
    n      no final newline-
    b word     repeated word -
    W Word context     Word-
    s string   data separator-
    p Precision    number of characters

Used to print sequences or random data.

Eg: produces random numbers between 1-4:
Jot-r 1 1 4

root@amax-02:~$ jot-r 1 1 4
1
root@amax-02:~$ jot-r 1 1 4 2 root@amax-02:~$
jot-r 1 1
4 2
root@ amax-02:~$ jot-r 1 1 4
2
root@amax-02:~$ jot-r 1 1 4 4 root@amax-02:~$
jot-r 1 1
4 2
Root@ama x:~$ jot-r 1 1 4
1
root@amax:~$ jot-r 1 1 4
3
root@amax:~$ jot-r 1
1 4 1
basename
Usage: basename name [suffix]
or: basename option
Print name with any leading directory components removed.
If specified, also remove a trailing SUFFIX.

The required parameters apply to the length and duration options.
  -A,--multiple       support multiple arguments and treat each as a NAME
  -S,--suffix=suffix  remove a trailing SUFFIX
  -Z,--zero           separate output with NUL rather than, newline and--help to        Display this help information and exit
      --version     display version information and exit

Examples:
  basename/usr/bin/sort          -> "Sort"
  basename include/stdio.h. h     -> "Stdio"
  Basename-s. h include/stdio.h  -> "stdio" basename-a any/str1 any/str2->   "str1" followed by "str2"

Please report basename errors
to bug-coreutils@gnu.org. Homepage of the GNU coreutils:
variable self-increasing
#!/bin/sh

a=1
a=$ (($a + 1))
a=$[$a +1]
a= ' expr $a + 1 ' let
a++ let
a+=1
((a++))
Echo $a
if
-eq #等于
-ne #不等于
-gt #大于
-ge #大于等于
-lt #小于
-le #小于等于
<   #小于 (requires double brackets)
<=  #小于等于 (requires double brackets)
> #大于 (requires double brackets)
>=  #大于等于 (double brackets required)

If [a > B];then
(Remember the blanks.) string spin digits

How to convert a string to a number in the shell.
For example: a= "024"

1, with ${{a}}

2, with Let to achieve (()) Operation effect.

Let num=0123;
echo $num; 
83

3, double bracket operator:

a=$ ((1+2));

echo $a;

Equivalent to:

A= ' expr 1 + 2 '

And the numbers will default to string processing.

Variable with single quote "Variable string"

I=1

echo ' $i ';

Output: $

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.