Chapter files and text search
Translation: hfzheng
E-mail: hfzheng@sohu.com
Reprinted Please keep this information!
Locate files using the find command
Use the find command to locate files in the directory tree, use the command can be based on specified rules to locate the file, for example, specify a file name, size, owner, modification time, type.
find command search path list recursive directory tree to find the rules to meet the specified file. When those who satisfy the conditions of the document orientation, the screen will display each file's path.
Command format
find pathnames expressions actions
The first command line argument for the start of the path name search, you can use an absolute path or relative path to specify. Search rules, and other parameters specified when searching files to the action to be taken. The following three sections describe the find command can be used in the parameters, expression and movement.
Parameter definition
pathname search the directory path beginning
expression of one or more options specified search rules, specify the number of search rules, find the command will execute and operate, that is, all listed in the search for rules that must be met.
Find command can be used in expressions
-Name filename search for files matching the specified file name, meta characters if placed inside the quotation marks can also be used
-Size [+|-] n search for the file size is greater than (+ n) or less than (-n) of the paper, n behalf of 512 byte blocks
-Atime [+|-] n search access to more than (+ n) or less (-n) days of the file
-Mtime [+|-] n search modified for more than (+ n) or less (-n) days of the file
-User loginID search for the name of all files belonging to loginID
-Type search for the file type specified, such as the d directory, f file
-Perm search with the specified file access permission
Find-print instructions to print the current path to the terminal screen, which is the default setting
find command can be used in action
-Exec command (); automatically find the file for each implementation of the specified command, must contain the string (); used to tell the find command for each file specified by the search rules for the implementation of command, must be a space before;
-Ok command (); exec interactive way, the results of the find command asks for confirmation when the command;
The following example find command functions:
$ Find /-name core
$ Find ~-name core-exec rm ();
$ Find.-Mtime +90
$ Find ~-size +57
$ Find / usr-name '* tif'
Compare the differences between files
Comparison of text using the cmp command differences between
Cmp command can be easily identified using the difference between the text. Only when the text file does not only print the results while cmp command, without any results, indicates that the file exactly the same.
cmp command for each file one byte a byte comparison, if the file had different, cmp command prints out the difference between the number of bytes of file and line number, then stopped in a different line. This command can compare binary files and ASCII files.
Command format
cmp filename1 filename2
$ Cmp fruit fruit2
fruit fruit2 differ: char 27, line 5
Output shows the two files the first time a different location, in the above example, line 5 in the first 27 characters.
Comparison of text using the diff command the difference between
Another diff is used to compare the differences between the command text. The command's result is a text file line by line show the differences between the two, as you edit a file to make the file and another file the same guidance.
Command format
diff-option filename1 filename2
Listed below can be used in the diff options:
-I Ignore case, for example, A is equal to a
-C generate a list of differences. Results file name and create date, the next is a group of stars, and then display the number of lines file1 file, file1 in the actual line, and file2 in front of different lines (-) label. Next is the file2 file lines, file2 in the actual line, with different line in front of file1 (+) tags.
Use with-c option of diff command
When using with the command diff-c option, the results shown in three parts.
The first part of the show to compare the file name, creation date, and then with a string of asterisks
The second part file1 file display, showing the number of lines the file file1, file1 in the actual line, and file2 different line in front of (-) label.
The third part file2 file shows the number of rows displayed file file2, file2 in the actual line, with a different line in front of file1 (+) tags.
For example, execute the following command to use diff to compare files:
$ Cat fruit
lemon
orange
apple
banana
pear
mango
tomato
pomegranate
$ Cat fruit2
lemon
orange
apple
banana
tomato
guava
mango
pomegranate
$ Diff-c fruit fruit2
backup bin conf config data eshow_sitemap.html generate.sh log maint sitemap.html svn tmp fruit Wed Jan 12 15:50:36 2000
--- Fruit2 Wed Jan 12 15:51:04 2000
backup bin conf config data eshow_sitemap.html generate.sh log maint sitemap.html svn tmp
backup bin conf config data eshow_sitemap.html generate.sh log maint sitemap.html svn tmp 2,8 backup bin conf config data eshow_sitemap.html generate.sh log maint sitemap.html svn tmp
orange
apple
banana
- Pear
- Mango
tomato
pomegranate
--- 2,8 ----
orange
apple
banana
tomato
+ Guava
+ Mango
pomegranate
$
Data sorting
sort command-line arrangement of text and print the file output to the screen. Sort command provides a quick alphabetical or numerical order organizational data. Default mode, sort order to use white space to separate different fields in the file.
Command format
sort-options filenames
Options
Available options include the definition of the type of order, starting from which the domain sort.
Digitally sort (+|-) n to n-separator start (+ n), end (-n) of the domain order
-R reverse sort
-F Ignore case
+ NM arranged the first three characters in domain name of the month as an abbreviation
-D arranged in directory order, consider only letters, numbers and spaces. Other characters ignore
-O filename output file to the specified filename
-B start and end of a limited sort domain omit the space character
-T char Use char as the field separator character, if not specified, the space character is used as the default parameter
Use the sort command with different options
The following example shows how to use the sort command with different options:
$ Cat fileA
Annette 48486
Jamie 48481
Fred 48487
Sondra 48483
Janet 48482
$
$ Sort fileA
Annette 48486
Fred 48487
Jamie 48481
Janet 48482
Sondra 48483
$ Sort +1 n fileA
Jamie 48481
Janet 48482
Sondra 48483
Annette 48486
Fred 48487
The first command to use cat command to display the contents of the file, the first alphabetical sort order, from the first character of each line start.
The second sort order by number field on the second order (use +1 to skip a delimiter syntax).
In a file in the different domains using the sort command
The following example describes how a file using the sort command in different domains:
$ Ls-ld f *> list
$ Cat list
-Rw-r - r - 1 user1 staff 218 Mar 1 11:36 feathers
-Rw-r - r - 1 user1 staff 218 Mar 1 11:36 feathers_6
-Rw-r - r - 1 user1 staff 0 Feb 25 12:54 file.1
-Rw-r - r - 1 user1 staff 0 Feb 25 12:54 file.2
-Rw-r - r - 1 user1 staff 0 Feb 25 12:54 file.3
-Rw-r - r - 1 user1 staff 1696 Feb 22 14:51 file1
-Rw-r - r - 1 user1 staff 156 Mar 1 14:48 file2
-Rw-r - r - 1 user1 staff 218 Feb 22 14:51 file3
-Rw-r - r - 1 user1 staff 137 Feb 22 14:51 file4
-Rw-r - r - 1 user1 staff 56 Feb 22 14:51 fruit
-Rw-r - r - 1 user1 staff 57 Feb 22 14:51 fruit2
$ Sort-rn +4 list-o num.list
$ Cat num.list
-Rw-r - r - 1 user1 staff 1696 Feb 22 14:51 file1
-Rw-r - r - 1 user1 staff 218 Mar 1 11:36 feathers_6
-Rw-r - r - 1 user1 staff 218 Mar 1 11:36 feathers
-Rw-r - r - 1 user1 staff 218 Feb 22 14:51 file3
-Rw-r - r - 1 user1 staff 156 Mar 1 14:48 file2
-Rw-r - r - 1 user1 staff 137 Feb 22 14:51 file4
-Rw-r - r - 1 user1 staff 57 Feb 22 14:51 fruit2
-Rw-r - r - 1 user1 staff 56 Feb 22 14:51 fruit
-Rw-r - r - 1 user1 staff 0 Feb 25 12:54 file.3
-Rw-r - r - 1 user1 staff 0 Feb 25 12:54 file.2
-Rw-r - r - 1 user1 staff 0 Feb 25 12:54 file.1
$ Sort +5 M +6 n list-o update.list
$ Cat update.list
-Rw-r - r - 1 user1 staff 56 Feb 22 14:51 fruit
-Rw-r - r - 1 user1 staff 57 Feb 22 14:51 fruit2
-Rw-r - r - 1 user1 staff 137 Feb 22 14:51 file4
-Rw-r - r - 1 user1 staff 218 Feb 22 14:51 file3
-Rw-r - r - 1 user1 staff 1696 Feb 22 14:51 file1
-Rw-r - r - 1 user1 staff 0 Feb 25 12:54 file.1
-Rw-r - r - 1 user1 staff 0 Feb 25 12:54 file.2
-Rw-r - r - 1 user1 staff 0 Feb 25 12:54 file.3
-Rw-r - r - 1 user1 staff 156 Mar 1 14:48 file2
-Rw-r - r - 1 user1 staff 218 Mar 1 11:36 feathers
-Rw-r - r - 1 user1 staff 218 Mar 1 11:36 feathers_6
$
The first example of the ls command output stored in the file list, and then use the cat command to view the file contents.
The first sort order on the fifth domain to generate a reverse, digital sequencing, sorting the results saved to file num.list in.
The second sort order of the file list of domains 6 and 7 for multi-sort options +5 M domain on the first six month of entries alphabetically, +6 n on 7 field days and a secondary sort in numerical order, all Sort results stored in update.list file.
Search the text of the document
Solaris operating environment provides a series of commands in one or more files used to search for a specific character patterns. Model can be a single character, string, word or sentence.
By definition, a search for matching characters in the same pattern as regular expression characters. Used to search for regular expressions command called grep, egrep and fgrep.
Grep command in a file search for regular expressions, regular expressions all contain the line to send the standard output.
Egrep and fgrep command is a variant of grep command, known as the rapid expansion of grep and grep.
Using the grep command
grep command is used in one or more files to search for character mode or regular expression to each line contains the specified character mode line output to the screen, but this does not change the contents of the file.
Command format
grep-options pattern filenames
Options
-I Ignore case, uppercase and lowercase letters that are the same
-L just lists the file name with a matching line
-N added before each line line number
-V lists all lines that do not match
-C only contains the pattern of the lines listed
Regular expression meta-characters
grep command supports a few dollars to further define the search mode character. Here are a few basic element commonly used character
^ Line start identifier '^ pattern' matches all lines that begin with pattern
$ Line end of the identifier 'pattern $' pattern match to the end of the line for all
. Matching a character 'p ... .. n' match all contain the five characters followed by p at the beginning, followed with a line of characters
* [A-z] * matches lowercase characters
[] Matches the pattern of a single character '[pP] attern' Pattern matching including the pattern and the pattern of lines
[^] Is not pattern matching a single character '[a ^ m] attern' match to a to m at the end of all rows attern
Using the grep command to search for examples of regular expressions
The following example uses the grep command to search for regular expressions to search files / etc / group contains a pattern in the root of all the line, execute the following command:
$ Grep-n root / etc / group
1: root:: 0: root
3: bin:: 2: root, bin, daemon
4: sys:: 3: root, bin, sys, adm
5: adm:: 4: root, adm, daemon
6: uucp:: 5: root, uucp
7: mail:: 6: root
8: tty:: 7: root, tty, adm
9: lp:: 8: root, lp, adm
10: nuucp:: 9: root, nuucp
12: daemon:: 12: root, daemon
$
To search for a file / etc / group does not contain all of the root mode of the line, execute the following command:
$ Grep-v root / etc / group
other:: 1:
staff:: 10:
nobody:: 60001:
noaccess:: 60002:
sun4prog:: 100:
funda:: 105:
cprg:: 170:
csh:: 180:
sysadmin:: 14:
fire:: 20:
sl300:: 30:
java:: 190:
cplus:: 700:
sysint:: 1000:
internals:: 2000:
sunnetmgr:: 3000:
OpenWindows:: 5000:
SAE:: 5500:
guest:: 20000: guest, kbrown
$
Just search for file name contains the model root, execute the following command:
$ Cd / etc
$ Grep-l root group passwd hosts
group
passwd
$
Need in the directory / etc all the files in search mode the, only listed the matching pattern and The file name, perform the following example:
$ Cd / etc
$ Grep-li the backup bin conf config data eshow_sitemap.html generate.sh log maint sitemap.html svn tmp
$ Cd / etc
$ Grep-li the backup bin conf config data eshow_sitemap.html generate.sh log maint sitemap.html svn tmp
aliases
asppp.cf
dacf.conf
device.tab
devlink.tab
dgroup.tab
fmthard
format
Whаt I didn't know was how I would get all of what I wanted in just six hours. Another thing you'll need іѕ some strength tо еndure,
ReplyDeletebеcаuse there's a good chance you'll be youг own prοducеr foг the show or perhapѕ the best prοducer the ѕhoω hаs.
Ιn much the same way, tωο-way radіo rental offeгѕ businesseѕ and indіviԁuаls substаntial ѕavіngs in
money, time and resouгceѕ thаt equiрment ownership neѵer ωіll.
Τаke a lοoκ at my ѕіte;
www.loesje.ru/index.php/index.php?title=Ideas-For-A-Dynamic-Online-Marketing-Strategy
My webpage - click through the following document
What i ԁo not undeгstoοd is actuаlly hoω уοu are no longer actually much more neatly-faѵorеd
ReplyDeletethan you may be now. Үоu're so intelligent. You already know therefore considerably on the subject of this topic, produced me in my opinion believe it from numerous varied angles. Its like men and women are not interested unless it is something to do with Girl gaga! Your own stuffs outstanding. Always maintain it up!
My web site: youtube downloader online
Tennis balls, wiffle balls, ping pong balls, and golf balls can also
ReplyDeletebe used. Each program will have a box with a checkmark,
find the programs you'd like to uninstall and uncheck that box. The player guides Phen through 10 levels of dungeon gameplay, finding a whole host of weapons and other items as well.
my web site myvideo downloader
my webpage - spiele spielen
There are many different kinds of tools and techniques required to deliver an exceptional SEO India results.
ReplyDelete''. The tools include efficient internet marketing, proper usage of keywords, flawless content and creating social media buttons.
Working with an SEO expert in your country can help as SEO experts within the same country generally know how to optimize websites for a specific country's audience more effectively. Since Google organic rank can bring in thousands of potential customers, search engine position service firms have made a business of promising high positions in search engine results pages. It would cut the marketing project to fit it into your budget. While these 5 truths may seem self-evident, it is the astonishing fact that they are contradicted, and even outright disputed, in the greater SEO debate. This means that they follow only the steps given to them by Google and other major search engines. The businesses have understood the need to take SEO services for attaining good search engine placement. Be sure that the SEO outsourcing company you hire is capable of communicating properly. Search engine optimization is necessary for online businesses because it lets your website get found. For instance, how many TV viewers then came to your car lot and purchased a vehicle. Moving your hosting to a nearby country such as Canada or an offshore Caribbean host may provide the same latency times, but reduce the risk of having your website brought down by a mistake. Such services also include some research that will need to be done so they can apply this research on major keyword. These professionals follow ethical SEO strategy and effectively implement it that finally increases your website visibility. It has been designed especially for business purposes and it holds biggest importance for your B2B online marketing strategy. Law firms face various challenges and have issues in remaining at the top in the market. SEO is becoming the most rewarding career nowadays. Such companies know the best about industry and market trends. SEO requires understanding of various algorithms.
Have a look at my web-site http://hospicenyc.org/hospice-support
If you have already tried everything else, however,
ReplyDeleteand none of it has been effective and you can get authorization from your physician,
gastric bypass surgery might be a good option for you.
Der primäre Punkt, halten den Sport übertragen in einem langsameren
Tempo kann die Art der Wette zu platzieren erwerben.
Jedoch das Schwierigkeit durch Diäten wie die Atkins Diät ist's, dass sie Sie setzen rein ernste Gefahr für Bluthochdruck und hohe Cholesterinwerte.
Here is my web page; Read the Full Piece of writing
Consiԁer running a сοntest or offering a free ρroduct tip shеet that acсοmpаnies the
ReplyDeleteinterѵiew. Intеrnal оr External Sоund Mixer
"All windows systems come with a internet sound mixer they all differ so you may need to review your manual or online sources to figure out how to enable or use it. Even if you have a good two way radio, it isn't bad to have some kind of receive only radio to get information on.
My weblog - simply click the next internet page
Great beat ! I would like to apprentice while you amend your site, how can i subscribe for a blog website?
ReplyDeleteThe account helped me a acceptable deal. I had been tiny bit
acquainted of this your broadcast offered bright clear idea
my web blog - Unterwasserkamera