Linux environment variables and file search

One

You can use  declare command creates a variable named tmp variable: $ tmp = shiyanlou

Reads the value of the variable, you can use  echo commands and  $ symbols ($ symbol used to represent the reference value of a variable, beginners often forget to enter), $ echo $ tmp

Note: Not all forms of variable names are available, the variable name can only be letters, numbers or underscores, and can not be used as a digital beginning.

 

Environment Variables scope than the custom variable to be large, such as Shell environment variables acting on its own and its children,

We variable type usually involve three ways:

  • Current Shell process private tmp variable user-defined variables, such as the above, we create only valid in the current Shell.
  • Shell itself is built-in variables.
  • Custom variables derived from environment variables.

There are also three commands related to the three environment variables: set, env, export.

 

Press the lifetime of variables to divide, Linux variables can be divided into two categories:

  1. Permanent: the need to modify the configuration file, variable permanent;

  2. Temporary: Use the command-line statement to export, variable fail when you close the shell.

Here are two important documents  /etc/bashrc(some Linux do not have this document) and  /etc/profile they were stored in a shell and environment variables, the .profile current user only permanent.

Written in  /etc/profile there is permanent for all users, so if you want to add a permanent environment variable, just open  /etc/profile, add the final environment variable you want to add a thousand million.

 

two

Adding a custom path to "PATH" environment variable, $ the PATH = $ the PATH : / Home / shiyanlou / mybin, pay attention here, be sure to use absolute paths.

Echo $ "$ PATH = PATH: / Home / shiyanlou / mybin" >> .zshrc, so that each can perform automatically add custom path to the PATH command above start Shell.

source Let command environment variables to take effect immediately.

Variable modifications:

Variable arrangement Explanation
${变量名#匹配字串} Start back from scratch match, delete data in line with the shortest matching string
${变量名##匹配字串} Start back from scratch match, delete the line with the longest matching string of data
${变量名%匹配字串} Matches start from the tail forward, delete data in line with the shortest matching string
${变量名%%匹配字串} Matches start from the tail forward, delete the line with the longest matching string of data
${变量名/旧的字串/新的字串} The first string in line with the old string is replaced with a new string
${变量名//旧的字串/新的字串} We will comply with all the old string

Variables Delete: You can use  unset the command to delete an environment variable  $ unset the TEMP

 

Command to search for files related whereisto: which, , find and  locate .

 

three

Packaging and decompress the file : On Linux, speaking before compression tool, it is necessary to first understand what common common compressed file formats. On Windows the most common nothing more than these two  *.zip, *.7z extension of the compressed file.

In common Linux format in addition to the above two above, as well as  .rar, *.gz, *.xz, *.bz2, *.tar, *.tar.gz, *.tar.xz, *.tar.bz2, briefly as follows:

File extension Explanation
*.zip packaged compressed zip file
*.rar rar file compression program
*.7z 7zip file compression program
*.tar tar packaged, uncompressed file
*.gz the gzip (GNU zip) compressed files
*.xz xz compressed program files
*.bz2 program bzip2 compressed file
*.tar.gz packaged tar, gzip file compression program
*.tar.xz tar package, xz compressed program files
*tar.bz2 tar package, bzip2 compressed program files
*.tar.7z tar package, 7z file compression program

 

  • zip:
    • Packaging: zip something.zip something (catalog please add -r parameter)
    • Unpack: unzip something.zip
    • Specify the path: -d parameter
  • taking:
    • 打包:tar -cf something.tar something
    • 解包:tar -xf something.tar
    • Specify the path: -C parameter

Guess you like

Origin www.cnblogs.com/CqMao/p/11402581.html