We all know that Linux can be operated with a variety of commands, there are quite a few commands for text processing, the following small series will be a summary of the Shell text processing tools in Linux, so that You have an understanding.
Under the Linux operating habits unlike windows can still be operated with a window, which is composed of many different command, this article will introduce the use of Shell under Linux text processing most commonly used tools: find , grep, xargs, sort, uniq, tr, cut, paste, wc, sed, awk
The examples and parameters provided are the most common and useful;
I am on shell scripts The principle of use is to write a single line of commands, try not to exceed 2 lines;
If you have more complex task requirements, consider python;
find file search (see System Home Linux) Find command common usage summary)
• Find txt and pdf files
The code is as follows:
find . \\( -name “*.txt” -o -name “*.pdf” \\) -print
• Regular way to find .txt and pdf
Codes are as follows:
find . -regex “.*\\(\\.txt|
\\.pdf\\)$”
-iregex: Ignore case-sensitive regulars
•negative parameters
find all non-txt text
code As follows:
find. ! -name “*.txt” -print
•Specify search depth
Print out the current directory file (depth is 1)
The code is as follows:
find . -maxdepth 1 -type f
Custom Search
•Search by Type:
The code is as follows:
find . -type d -print //List all directories only
-type f File /l Symbolic link
•Search by time:
-atime Access time (unit It is day, the minute unit is -amin, the following is similar)
-mtime modification time (content is modified)
-ctime change time (metadata or permission change)
All files that have been accessed in the last 7 days:
The code is as follows:
find . -atime 7 -type f -print
•Search by size:
wword k MG
Find files larger than 2k
The code is as follows:
find . -type f -size +2k
Find by permission:
The code is as follows:
find . -type f -perm 644 -print //Find all files with executable permissions
Find by user:
The code is as follows:
find . -type f -user weber -print//Find files owned by user weber
Follow-up actions after finding
•Delete:
Delete all current directories Swp file:
The code is as follows:
find . -type f -name “*.swp” -delete
Previous1234567Next page Total 7 pages
A lot of people want to know how to close a website on a Linux server because the website is on the
log4cxx log library is a dynamic library for logging c++ logs, then how to install log4cxx log libra
Some users have installed BackTrack for their computer, which is a professional Lin
We all know that the command to find files under Linux is the find command. With this command, you c
CentOS 6.2 upgrade yum prompt libotf.so.0 error how to do?
How to solve the problem of Linux not releasing disk space
How to share files between Ubuntu and Windows
How to initialize the CentOS server
Linux Logo Command Line Tool Installation and Use
Linux to increase the resolution of VirtualBox
How to boot Linux ISO image file from hard disk
How to modify the network card DNS in Linux system?
How to quickly clear Linux file content
Tianya Mingyue Knife Recruitment Activity Address and Activity Reward Collection Address
Edge browser extensions appear! Microsoft online official website
How to install a wireless printer in Win8 system?
How to solve the problem with the computer
Top 10 news in the technology industry in 2012: Windows 8 debut