UNIX common command

xiaoxiao2021-03-06  40

Batch killing process

> KILL -9 `PS -AEF | GREP process_name | awk '{print $ 2}'`> ps --aef | grep process_name | awk '{print $ 2}' | xargs -i -t kill {}

2. Batch change file content

#! / bin / sh # name: RS4D - Replace String for Current Directory Recursively.

Usage = "USAGE: SHISScript Oldstring Newstring" [$ 1 "-a -n" $ 2 "] || {echo $ usage; exit 0;}

D = `PWD`echoecho" CAUTION: All Subdirs May Be Affected! "Echoecho" Dir: $ D "echo" old string: / "$ 1 /" "echo" new string: / "$ 2 /" "echo" Correct? [ Y / n] "

Read flag [$ flash == "y"] || {EXIT 0;} Print "OK"

For i in `Find. -EXEC GREP -L $ 1 {} /;` Doecho Editting $ IED -S $ I << EOF 1, / $ S / $ 1 / $ 2 / g Weofdone

3. Batch file rename

Recycling #cat c_filenamesource = *. $ 1TARGET = $ 2for F in $ source; do base = `Basename $ f. $ 1` mv $ f $ base. $ 2done # The End replacement for file in` Find. `; Do file = `echo $ file | tr '[AZ]' '' [AZ] '` [$ file! = $ file] && mv $ file $ file done Remove space has a series of files, (have spaces in the middle of the file): Shortcut TO ACDSEE32.EXE.LNK SHORTCUT to EXESCOPE.EXE.LNK Shortcut to Fterm.exe.Lnk ... How to remove "shortcut to" in the file name? Method 1: LS | SORT | awk '{print "MV /" "$ 0" / "/" "}' | SED S / Shortcut / to / // 2 | SH regular expression" / 2 "/ 2 "The meaning is" the second one in each row "." Method 2: While read file; do evAl MV / '$ file /' `Echo $ file | sed 's / shortcut / to / // G'` DONE <

转载请注明原文地址:https://www.9cbs.com/read-73315.html

New Post(0)