Shell编程- 文件
The following is the most frequently used file command
1 cat, show file content
cat zdd.txt, show content of zdd.txt
cat file1 file2 ... filen
-n, show line number
-b, skip empty line
2 wc, count the character, word, and line of a file
wc zdd.txt (multiple file is ok, wc file1 file2 ... filen)
output:
53 276 1620 zdd.txt - 53 lines, 276 words, 1620 characters
-l, count line
-w, count word
-c, count character
if no argument provide, count all of the 3 above
3 cp, make a copy of a file, this command has no output except it encounterd an error
cp source, dest
cp file1 file2, create a copy of file1 in the same folder
cp file1 directory1, create a copy of file1 under directory1, cp zdd.txt Work/ , create a copy of zdd.txt under folder 'Work'
cp file1 file2 ... filen dir, copy file1 - filen to folder 'dir', note in this case, dir must be a foler!
-i, interactive mode, promote before overwrite
4 mv, rename file
mv source, dest
mv zdd.txt ddz.txt, rename zdd.txt to ddz.txt
-i, interactive mode, promote for overwirte(ddz.txt already exist)
4.1 mv, move source files to destiny directory
5 rm, delete file
rm file1 file2 ... filen
-i, interactive mode, promote before delete(delete file is unrecoverable)