A practical line of Linux commands-general Linux technology-Linux technology and application information. The following is a detailed description. The following Linux commands have only one line, which is short but practical. If you are good at using them, it will bring convenience to your Linux use process. These include creating an archive file, recursively searching for strings in the file, searching and replacing the content in the file, and viewing disk and directory usage.
Create an archive file
Tar-czpf folder_name.tar.gz folder_name
This command creates folder_nameas the folder_name.tar.gz archive file.
Recursively search for strings in a file
Find./-name '*. html'-exec grep "breadcrumbs. inc. php" '{}' \;-print
This command will search for all HTML files containing breadcrumbs. inc. php.
Search and replace the content in the file
Sed-I's/B/strong/G' index.html
This command searches for B in the index.html file and replaces it with strong.
View the disk usage of the Directory
Du-h -- max-depth = 1 | sort-n-r
Replies from some netizens:
View the disk usage of the Directory
Du-h? Max-depth = 1 | sort-n-r
I think it is better to use du-hs to achieve this purpose.
In the man manual, max-depth = 1 is the same as-s.
Add a few less commonly used ones.
Ls-ltr (ll-tr) is sorted by time. The latest modified files are listed at the bottom.
Ls-Slhr (ll-Shr) sorting by file size is the largest at the bottom
Recursively search for characters in a file
This is simpler:
Grep-ri "test string" *. html
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.