Chapter pipe symbol, redirection and environment variable July 17, 2019 Wednesday Lesson

2019 Nian 7 Yue 17 Wednesday Lesson

2.7 directory management commands

1 , Touch command to create a blank file or set file time

如:touch haha.txt

    touch -d "19:00"    modify file access and to modify the time

-a modification time reading    -m modification modified -d The first two are modified

2, mkdir command creates a directory

If you want to create a directory iterative relationship to add parameters  -p

Such as: mkdir -pa / B / C / D / E / F / G

3, cp command to copy a file or directory

To add parameters to copy the directory -r

如:cp -r Music/ haha

4, mv command cut and renaming files or directories

Operating under the same directory for renaming

5, rm command to delete a file or directory

Parameters -f    forcibly remove (do not ask)

     -r    When you delete a directory to add

6, dd command to copy data or converted in accordance with the specified size and number of blocks

Parameters if input file     file source

  of outout file    output file

  count             block

  bs                size

如:dd if=xiao.cfg of=da.cfg bs=20 count=1

    To xiao.cfg take 2OK , take a secondary output to da.cfg

7, file command to view the file types

In linux everything is a file, the file directory is also included, so the file can also view the catalog file type.

2.8 packaged compression and search command

1 , tar commands for file compression or decompression package

Common parameters: 1 , -czvf

            c create a compressed file

            the gzip = Z ZIP or j = bz2

            v display compression process

            f the compressed file name

Such as: tar -czvf archive name .tar.gz source file

2, -xzvf

x   Extract the files

Such as: tar-xzvf archive name .tar.gz

2 , grep command to perform keyword searches, and display the results

  Such as: grep keyword source file

To display the number of rows can be added parameter -n

Such as: grep -n keyword source file

3 , the Find command to find files

Such as: Find / -name fstab

"/" Refers to the root directory, comprehensive search

" -Name " to match the file name

fstab as keywords

If no search results, there is no return value

Parameters -prune (ignoring a directory) must -path used simultaneously

如:find / -path /root -prune -name fstab

Chapter  pipe symbol, redirection and environment variable

3.1 Input and output redirection

The command written to the output file as: LS -l> haha

Output redirection

> Clear write

>> additional writing

2>       given written emptied

>> 2 additional write error

&> Whether or not an error, all output is redirected

Input redirection

<File import

As: WC -l <Anaconda-import the file into the ks.cfg command

 

3.2 Pipe command character

| Pipe character input before the output command to be processed later command

Such as: command A | B transmits commands command input to the command information A B

ls | wc -l the number of files in the directory Statistics

ps aux | grep ssh ssh statistical information on the process of

3.3 command line wildcard

* Can match or null character

? Only match one character

[] Matches the specific characters, separated by commas, such as: [1,3,5], or [1-9] , [AZ]

3.4 commonly used escape

1 , ""   in order to avoid errors caused by the space program, selecting "" into a whole.

如:echo “hello word!”

2 , \    the operator later transformed into a pure character

Such as: PRICE =. 5

echo “Price is \$$PRICE”

The resulting output is: Price IS $ 5

3 , 'global escape, the' inside all operators characters transformed into pure

4 , `` content within backticks as a command

Guess you like

Origin www.cnblogs.com/gbqs/p/11198806.html