I have been using Linux recently and have accumulated some experience and skills. I will share it with you.
1. view the number of objects
WC-l filepath
2 File Sorting
Sort-K1-K2-T ""-n-r filepath
The command above is to sort the file records in reverse order according to the first column and the second column, with the separator \ t.
Note: When sorting in Chinese, you need to specify lc_all = C for sorting. Command lc_all = C sort-K1-K2-T ""-n-r filepath
3. view the current process
PS UX
4. view the resources occupied by the Process
Top Ctrl + C Exit
5. View hard disk and memory
DF-H/free
6 ShellProgramParameters in
$ # Number of parameters
$1 first parameter, $2 second parameter
Size = 1
$ {! Size} represents the first parameter, that is, when you use a variable to replace a number, you need to use $ {! Varible} format.
You can use ''to include a script to save the return value of the entire script.
For example, if the result is 'Ls', the result will be saved with the return result of LS.
7. Use nohup sh run. Sh & submit the task
In this way, the running of the program is not affected when the network is interrupted. Otherwise, the program will fail due to network interruption.
8 program output
Generally, the program uses> redirect output, such as CAT a.txt> B.
But some programs may have outputs and error outputs. How can this problem be formulated?
Sh-x run. Sh 1> out 2> err. Note that there must be no space between 1, 2, and>. continuous input is required.
9 MPs queue usage
If you have a series of simple operations, you can use pipelines. For example
Cat input | sort | uniq> B
In this way, the result is output to B after the input is deduplicated, which is more convenient.
For the time being, I think of these commonly used ones. Many people are also very familiar with them, so I will not elaborate on them.
Welcome to shoot bricks ~~