Common Programming and example of Shell on: http://blog.csdn.net/larrylgq/article/details/7333632
1: ls * | while read FN; do grep-V ', 11,1108, 1133,110816, 110816' $ FN>/data1/hadoop/back_up/tmp/$ {fn} _ 08171819; done
Ls * output
| Media transcoding queue. The preceding output is used as the input.
Grep Filtering
-V reverse lookup
-> The meaning of the first command is to traverse all the files in the current folder and use while for a loop. Execute the following command for each file: reverse lookup the files whose names are not ', 11,1108, 1133,110816, 110816, output the file to/data1/hadoop/back_up/tmp/with the current file name + _ 08171819/
2: ls * _ 110816 *. GZ | while read FN; do gunzip-C $ FN> multiple bytes fn1_.gz}. log; done
Put * _ 110816 *. GZ-matching compressed file-zcvf (forcibly extract all information and create a package),-C (create)-VF (vebose, force)-x decompress -z(.gz) to package
-> The second command indicates that each file name (FN) is read cyclically. The loop body do splits the file into a gunzid file and then outputs the file FN + Gz. log.
3: ls/datacenter/hadoop/back_up/20110920/View/10096 | while read FN; do cut-d', '-F7 $ FN; done | grep '000000' | WC-l
Cut-d', ', used as the separator-F7 to find the 7th Columns
Cut-B 1-10 bytes
Count the number of rows (-l)
-> The third command indicates a loop/datacenter/hadoop/back_up/20110920/View/10096 file, which splits each entry of each file and outputs 7th columns, in this column, find the 110919
4: Kill 'ps aux | grep Java | grep-V grep | awk {'print $2 '}'
Kill and kill Processes
Kill the process to be killed. A process number is returned when the anti-code is used.
Awk
{''} Inside the loop
Print $2 print the second one
-> The fourth command indicates to find a Java Process without grep and return the process number.
5: For (I = 3; I <11; I ++); Do echo $ I; SSH 10.10.10. $ I 'Find/datacenter/infobright/panel/{view, click}-type F-exec WC {}\; '; done
Log on to 10.10.10.3-11 using SSH.
Find search operation
-Type F: Find all files. D is the directory.
-Exec: execute shell commands
{} \; Returns and returns
-> The Fifth command means to log on to the 8 machines 3-11 to search for all the files under/datacenter/infobright/panel/{view, click} and execute WC (wordcount)
Find ~ /Desktop/log-type F-exec WC-l {}\;
6: delete files 7 days ago by file name
#! /Bin/bash
# Deleting files 7 days ago
Pathadx =./ADX
Del_date = 'date + % Y % m % d-d "7 days ago "'
For N in 'Find $ {pathadx}-name' *-r-* ''; do
File_dt = 'echo $ n | awk-F/'{print $5}' | cut-B 1-8'
If [[$ file_dt <$ del_date]; then
# Echo $ N;
# Echo $ del_date;
# Echo $ file_dt;
Rm-RF $ n
Fi
Done