Linux basic commands

Source: Internet
Author: User
Tags aliases

Find/root/data-type f-exec rm-rf {} \;

Find/root/data-type F | Xargs rm-f
Find-type to find by file type

Delete all files in a directory, but keep a specified file
Method One:
find/root/-type F! -name "File10" | Xargs rm-f
find/root/-type F! -name "File10"-exec rm-rf {} \;

-exec processing the results of a lookup (processing the previous result)
{} indicates what was found
\; Translated

When copied, the same name does not prompt for overwriting
/bin/cp/mnt/test.txt/tmp/test.txt Full path
\cp/mnt/test.txt/tmp/test.txt plus \

Alias setting aliases
Unalias Canceling aliases

See only 20 to 30 lines of one file
head-30 Test.txt | Tail-11
Print line number
Sed-n ' 20,30p ' test.txt

Sed ' s#oldboy#oldgirl#g ' test.txt replaces Oldboy with Oldgirl (only replaces output, file is not replaced)
Sed-i ' s#oldboy#oldgirl#g ' test.txt means replace G for global, #可以用/@ replace


Seq
Tail-f Real-time changes to trace files

awk filters content, prints, deletes
Filter content (Fetch columns)
awk ' {print '} ' files in the first column, $ two in the second column
Awk-f ":" ' {print $} ' file-F is the flavor delimiter
Awk-f ":" ' {print $ ', ' $ $ ', ' $ $} ' in the middle of a comma to split

awk ' {if (nr<31 && nr>19) printf $ "\ n"} ' test.txt NR is line number


Find/root/data-type f-name "Test.txt" | Xargs sed-i ' s/oldboy/oldgirl/g '

Linux basic commands

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.