Linux common file operation command set 1. create a file dd [wang @ localhost desktop] $ ddif/dev/zerooftest. databs1Kcount22 + 0recordsin2 + 0recordsout2048bytes (2.0kB) copied, 0.00112496 seconds ,... linux common file operation command set 1. create a file dd [wang @ localhost desktop] $ dd if =/dev/zero of = test. data bs = 1 K count = 22 + 0 records in2 + 0 records out2048 bytes (2.0 kB) copied, 0.00112496 seconds, 1.8 MB/second, where if indicates the input file, of indicates the output file, bs indicates the block size, and count indicates the number of blocks to be copied. Use touch filename 2 to create a blank file. file intersection and difference set comm [wang @ localhost desktop] $ sort B .txt-o B .txt [wang @ localhost desktop] $ sort a.txt-o a.txt [wang @ localhost desktop] $ comm a.txt B .txt: the line [wang @ localhost desktop] $ comm a.txt B .txt-1-2acdf-1 indicates killing the first column, -2 indicates killing the second column, which is used to take the intersection. 3. create a long Directory mkdir [wang @ localhost desktop] $ mkdir-p. /william/wang/2013 this command will create the william, wang, 2013 directory in sequence 4. view file information file [wang @ localhost desktop] $ file shell. sh shell. sh: Bourne-Again shell script text executable [wang @ localhost desktop] $ file-B shell. sh Bourne-Again shell script text executable // only list file types 5. search for file differences and fix diff [wang @ localhost desktop] $ diff-u a.txt B .txt --- a.txt 2013-03-26 14:17:00. 265890952 + 0800 ++ B .txt 14:16:55. 439744576 + 0800 @-+ @-a-B c d-e f-g + I [wang @ localhost desktop] $ diff-u a.txt B .txt> c. patch [wang @ localhost desktop] $ patch-p1 B .txt <c. patch missing header for uniied diff at line 3 of patchpatching file B .txt Reversed (or previusly applied) patch detected! Assume-R? [N] y [wang @ localhost desktop] $ cat B .txt abcdefgnow B .txtand a.txt have the same content. 6. print the lines above or below [wang @ localhost desktop] $ head-n 3 B .txt AB [wang @ localhost desktop] $ tail-n-2 B .txt fg [wang @ localhost desktop] $ tail-f/var/log/messagestail: unable to open "/var/log/messages" to read data: the permission is insufficient. tail: no files remaining [root @ localhost desktop] # tail-f/var/log/messages // tracking log Mar 26 13:57:13 localhost dhclient: bound to 192.168.126.148 -- renewal in 706 seconds. mar 26 14:08:59 localhost dhclient: DHCPREQUEST on eth0 to 1 92.16126.254 port 67Mar 26 14:08:59 localhost dhclient: DHCPACK from 192.168.126.254Mar 26 14:08:59 localhost dhclient: bound to 192.168.126.148 -- renewal in 876 seconds. you can also use this function: [root @ localhost desktop] # dmesg | tail-f 7. only list the directories [wang @ localhost desktop] $ ls-d */mm/[wang @ localhost desktop] $ ls-l | grep "^ d" drwxrwxr-x. 2 wang 4096 01-25mm 8. switch the last two directories to [wang @ localhost desktop] $ cd-/home/wang/project [wang @ l Ocalhost project] $ cd-/home/wang/desktop [wang @ localhost desktop] $9. find the matched file [wang @ localhost desktop] $ grep-l "bin ". -r. /mm/test. sh. /shell. sh. /bt. sh. /test1.sh. /startup. x 10. split the file [wang @ localhost desktop] $ cut-f2, 3-d ":"/etc/passwdx: 0x: 1x: 2 11. find the file and operate the find path-name "file"-exec "command" {}\; [wang @ localhost desktop] $ find. -name "a.txt"-exec cp {}/home/wang/project/\; [wang @ localhost desktop] $ ls/home/wang/project/12. replace sed [Wang @ localhost desktop] $ echo WO | sed's/WO/wo/2G 'Wo WO wo can be replaced from the second matched place. if not 2, replace all. [Wang @ localhost desktop] $ echo WO | sed's/WO/wo/g' wo [wang @ localhost desktop] $ echo WO | sed's /WO/wo/'Wo wo [wang @ localhost desktop] $ echo linux is 2 | sed's/is \ ([0-9] \) /\ 1/'Linux 2is followed by a number to replace it with the matching first field.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service