In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
The previous words
I think the front-end engineer may not need the Shell command. But when learning Git, I found that in addition to the Git command, there are a lot of Shell commands to cooperate with. Therefore, Shell commands need to be systematically studied and summarized. This article will introduce the common commands of shell in detail.
Special character
Special characters have a special meaning to shell, so don't use them as ordinary characters. Some special characters are used for regular expression matching
&; | *?'"`[] () $
< >{} # /\! ~
Blank character
Although RETURN, SPACE and TAB are not special characters, they have special meanings to shell.
The RETURN key is usually used to end the command line and start the execution of the command
The SPACE and TAB keys are used as delimiters on the command line
Escape character
To use special characters as ordinary characters, escape references to them
[note] the slash (/) cannot be escaped, it always represents the delimiter in the path name
The special characters can be escaped by adding a backslash (\) before the special characters. To escape two or more consecutive special characters, you must precede each character with a backslash (\)
Another way to escape special characters is to enclose them in single quotation marks ('*'), or you can enclose special characters and ordinary characters in a pair of single quotation marks.
Catalog correlation
Show directory path
[pwd] displays the current directory
[note] if you use the Windows system, in order to avoid all kinds of inexplicable problems, please make sure that the directory name (including the parent directory) does not contain Chinese
Switch directories
[cd] switch to another working directory, and the parameter direction is the path name of the directory to be specified as the new working directory.
Cd [options] [direction]
If you do not take any parameters, or use the tilde (~), change to the home directory
Use a hyphen (-) to switch to the previous working directory
Use double periods (..) To return to the directory one level up under the current directory
Create a directory
[mkdir] create a directory. If a directory with the same name already exists, it cannot be created successfully.
Mkdir [option] directory-list
Delete directory
[rmdir] Delete a directory. If it is not empty, it cannot be deleted successfully.
Rmdir directory-list
File correlation
Show all files
[ls] is similar to the dir command under dos and is used to display information about one or more files
By default, ls lists the information of files in alphabetical order of file names
Ls [options] [file-list]
Options has many options, and the common options are as follows
Ls-a displays all files, including the hidden file ls-F, adding symbols to the end of the file to indicate the file type. * indicates executable, / indicates directory, @ indicates link file ls-l lists more detailed information of each file ls-R recursively lists the contents of the subdirectory ls-t displays the files in the order of the last modification time
When file-list contains a directory, ls displays the contents of that directory
Ls mygit displays files in the mygit directory ls g* displays all files that begin with the letter g
Show file contents
[cat] displays the contents of a text file, similar to the type command under dos
Cat [options] [direction] cat file1 displays the contents of the file1 file cat file1 file2 displays the contents of the file1,file2 in turn cat file1 file2 > file3 combines the contents of the file1,file2 and then redirects (>) to the file3 file
">" is the right redirector, which means that the result of the command on the left is regarded as the input of the command on the right. If the file on the right is an existing file, its original contents will be emptied and become the command output on the left. If you want to write as an append, use the ">" redirector instead
Rewrite a file
If there is no specified file on the left side of ">", such as cat > file1, it will wait for the user to enter, and then press [Ctrl] + [d] after the input is finished. The user's input will be written to file1.
Delete a file
[rm] Delete files, similar to the del/erase command under dos
Rm [options] file-list
Options has many options, and the common options are as follows
The rm-I system will ask for confirmation before deleting the file. After the user replies y or Y, the file will really be deleted. Rm-r recursively deletes the contents of the specified directory, including all subdirectories and the directory itself rm-f and-I parameters are opposite.-f indicates the forced deletion of the file name of each file that is deleted by rm-v.
Copy a file
[cp] copy files
Cp [options] source-file destination-filecp [options] source-file-list destination-directory
Use the cp command to make a copy of a file
You can also copy one or more files to a directory using the cp command
Cp-R recursively copies a directory hierarchy that contains ordinary files
Move files or rename
[mv] rename or move a file
Mv [options] existing-file new-filenamemv [options] existing-file-list directionmv [options] existing-direction new-direction
Use the mv command to rename a file
Use the mv command to move one file to another directory
Use the mv command to move a file to another directory and rename it
You can also move directories using the mv command
Create a new file
[touch] create a new file, or change the access and modification time of the file
Touch [options] file-list
Touch is used to create a new file when the file with the same name does not exist
When a file with the same name exists, touch is used to modify the access and modification time of the file
File Advanced
Compare files
[cmp] compare two files byte by byte. If the two files are the same, cmp does not display anything; otherwise, cmp will display the number of bytes and line number corresponding to the first difference.
Cmp [options] file1 [file2 [skip1 [skip2]
Display is different
[diff] displays the difference between the two text files by line. By default, you can edit one of the files to be the same as the other according to the difference shown by diff
Diff [options] file1 file2diff [options] file1 directorydiff [options] directory file2diff [options] directory1 directory2
File1 and file2 are the pathnames of plain text files to be compared by diff. When file2 is replaced by the directory parameter, diff will look for files with the same name as file1 in the directory directory; similarly, when file1 is replaced by directory, diff will look for files with the same name as file2 in the directory directory; when two directory parameters are specified, diff will compare two files with the same simple file name in the directory1 directory as in the directory2 directory
1c1 means to change the first line of a.txt to be the same as the first line of b.txt
Statistics
[wc] displays the number of lines, words, and bytes
Wc [options] [file-list]
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.