LPI Linux Certification in a Nutshell Part 6
You’re reading novel LPI Linux Certification in a Nutshell Part 6 online at LightNovelFree.com. Please use the follow button to get notification about the latest chapter next time when you visit LightNovelFree.com. Use F11 button to read novel in full-screen(PC only). Drop by anytime you want to read free – fast – latest novel. It’s great if you could leave a comment, share your opinion about the new chapters, new novel with others on the internet. We’ll do our best to bring you the finest, latest novel everyday. Enjoy!
Frequently used options -tnumber Specify Tab stops in place of the default 8.
-i Initial; convert only at start of lines.
Name fmt Syntax fmt[options][files]
Description Format text to a specified width by filling lines and removing newline characters. Multiple files files from the command line are concatenated. from the command line are concatenated.
Frequently used options -u Use uniform s.p.a.cing: one s.p.a.ce between words and two s.p.a.ces between sentences.
-w width width Set line width to width width. The default is 75 characters.
Name head Syntax head[options][files]
Description Print the first few lines of one or more files (the "head" of the file or files). When more than one file is specified, a header is printed at the beginning of each file, and each is listed in succession.
Frequently used options -c n n Print the first n n bytes, or if bytes, or if n n is followed by is followed by k k or or m m, print the first n n kilobytes or megabytes, respectively. kilobytes or megabytes, respectively.
-nn Print the first n n lines. The default is 10. lines. The default is 10.
Name join Syntax join[options]file1file2 Description Print a line for each pair of input lines, one each from file1 file1 and and file2 file2, that have identical join fields join fields. This function could be thought of as a very simple database table join, where the two files share a common index just as two tables in a database would.
Frequently used options -j1field Join on field field of of file1 file1.
-j2field Join on field field of of file2 file2.
-jfield Join on field field of both of both file1 file1 and and file2 file2.
Example Suppose file1 file1 contains the following: contains the following: 1one 2two 3three and file2 file2 contains: contains: 111 222 333 Issuing the command: $join-j1file1file2 yields the following output: 1one11 2two22 3three33
Name nl Syntax nl[options][files]
Description Number the lines of files files, which are concatenated in the output. This command is used for numbering lines in the body of text, including special header and footer options normally excluded from the line numbering. The numbering is done for each logical page logical page, which is defined as having a header, a body, and a footer. These are delimited by the special strings ::: :::, :: ::, and : :, respectively.
Frequently used options -b style style Set body numbering style to style style, which is t t by default (styles are described next). by default (styles are described next).
-f style style Set footer number style to style style ( (n by default). by default).
-h style style Set header numbering style to style style, (n by default). by default).
Styles can be in these forms: A Number all lines.
t Number only nonempty lines.
n Do not number lines.
pREGEXP Number only lines that contain a match for regular expression REGEXP REGEXP.
Example Suppose file file1 file1 contains the following text: contains the following text: ::: header :: line1 line2 line3 : footer ::: header :: line1 line2 line3 : footer If the following command is given: $nl-hafile1 the output would yield numbered headers and body lines but no numbering on footer lines. Each new header represents the beginning of a new logical page and thus a restart of the numbering sequence: 1header 2line1 3line2 4line3 footer 1header 2line1 3line2 4line3 footer
Name od Syntax od[options][files]
Description Dump files in octal and other formats. This program prints a listing of a file's contents in a variety of formats. It is often used to examine the byte codes of binary files but can be used on any file or input stream. Each line of output consists of an octal byte offset from the start of the file followed by a series of tokens indicating the contents of the file. Depending on the options specified, these tokens can be ASCII, decimal, hexadecimal, or octal representations of the contents.
Frequently used options -t type type Specify the type type of output. of output.
Typical types include: A Named character c ASCII character or backslash escape O Octal (the default) x Hexadecimal Example If file1 file1 contains: contains: a1n A1n where n n stands for the newline character, the stands for the newline character, the od od command specifying named characters yields the following output: command specifying named characters yields the following output: $od-tafile1 00000000a1nlA1nl 00000006 A slight nuance is the ASCII character mode. This od od command specifying named characters yields the following output with backslash-escaped characters rather than named characters: command specifying named characters yields the following output with backslash-escaped characters rather than named characters: $od-tcfile1 00000000a1nA1n 00000006 With numeric output formats, you can instruct od od on how many bytes to use in interpreting each number in the data. To do this, follow the type specification by a decimal integer. This on how many bytes to use in interpreting each number in the data. To do this, follow the type specification by a decimal integer. This od od command specifying single-byte hex results yields the following output: command specifying single-byte hex results yields the following output: $od-tx1file1 0000000061310a41310a 00000006 Doing the same thing in octal notation yields: $od-to1file1 00000000141061012101061012 00000006 If you examine an ASCII chart with hex and octal representations, you'll see that these results match those tables.
Name paste Syntax paste[options][files]
Description Paste together corresponding lines of one or more files files into vertical columns. Similar in function to the into vertical columns. Similar in function to the join join command, but simpler in scope. command, but simpler in scope.
Frequently used options -dn Separate columns with character n n in place of the default Tab. in place of the default Tab.
-s Merge lines from one file into a single line. When multiple files are specified, their contents are placed on individual lines of output, one per file.
For the following three examples, file1 file1 contains: contains: 1 2 3 and file2 file2 contains: contains: A B C Example 1 A simple paste paste creates columns from each file in standard output: creates columns from each file in standard output: $pastefile1file2 1A 2B 3C Example 2 The column separator option yields columns separated by the specified character: $paste-d'@'file1file2 [email protected] [email protected] [email protected] Example 3 The single-line option (-s) yields a line for each file: $paste-sfile1file2 123 ABC
Name pr Syntax pr[options][file]
Description Convert a text file into a paginated, columnar version, with headers and page fills. This command is convenient for yielding nice output, such as for a line printer from raw, uninteresting text files. The header will consist of the date and time, the filename, and a page number.
Frequently used options -d Double s.p.a.ce.
-hheader Use header header in place of the filename in the header. in place of the filename in the header.
-llines Set page length to lines lines. The default is 66.
-o width width Set the left margin to width width.
Name sort Syntax sort[options][files]
Description Write input to stdout stdout (standard out), sorted alphabetically. (standard out), sorted alphabetically.
Frequently used options -f Case-insensitive sort.
-kPOS1[,POS2]
Sort on the key starting at POS1 POS1 and (optionally) ending at and (optionally) ending at POS2 POS2.
-n Sort numerically.
-r Sort in reverse order.
-tSEP Use SEP SEP as the key separator. The default is to use whites.p.a.ce as the key separator. as the key separator. The default is to use whites.p.a.ce as the key separator.
Example Sort all processes on the system by resident size (RSS in in ps ps): $psaux|sort-k6-n USERPID%CPU%MEMVSZRSSTTYSTATSTARTTIMECOMMAND root20.00.000?SWFeb080:00[keventd]
root30.00.000?SWNFeb080:00[ksoftirqd_CPU0]
root40.00.000?SWFeb080:01[kswapd]
root50.00.000?SWFeb080:00[bdflush]
root60.00.000?SWFeb080:00[kupdated]
root70.00.000?SWFeb080:00[kjournald]
root5200.00.31340392tty0SFeb080:00/sbin/mingettytt root3350.00.31360436?SFeb080:00klogd-x root10.00.31372480?SFeb080:18init daemon4680.00.31404492?SFeb080:00/usr/sbin/atd root3300.00.41424560?SFeb080:01syslogd-m0 root4540.00.41540600?SFeb080:01crond root31300.00.52584664pts/0R13:240:00psaux root4020.00.62096856?SFeb080:00xinetd-stayalive root3850.00.926241244?SFeb080:00/usr/sbin/sshd root5300.00.922481244pts/0SFeb080:01-bash root31310.00.922481244pts/0R13:240:00-bash root4200.01.346201648?SFeb080:51sendmail:accepti root5290.01.536241976?SFeb080:06/usr/sbin/sshd
Name split Syntax split[option][infile][outfile]
Description Split infile infile into a specified number of line groups, with output going into a succession of files, into a specified number of line groups, with output going into a succession of files, outfile outfileaa, outfile outfileab, and so on (the default is xaa xaa, xab xab, etc.). The infile infile remains unchanged. This command is handy if you have a very long text file that needs to be reduced to a succession of smaller files. This was often done to email large files in smaller chunks, because at one time it was considered bad practice to a send a single large email message. remains unchanged. This command is handy if you have a very long text file that needs to be reduced to a succession of smaller files. This was often done to email large files in smaller chunks, because at one time it was considered bad practice to a send a single large email message.
Frequently used option -n Split the infile infile into into n n-line segments. The default is 1,000.
Example Suppose file1 file1 contains: contains: 1one 2two 3three 4four 5five 6six Then the command: $split-2file1splitout_ yields as output three new files, splitout_aa splitout_aa, splitout_ab splitout_ab, and splitout_ac splitout_ac.
The file splitout_aa splitout_aa contains: contains: 1one 2two splitout_ab contains: contains: 3three 4four and splitout_ac splitout_ac contains: contains: 5five 6six
Name tac Syntax tac[file]
Description This command is named as an opposite for the cat cat command, which simply prints text files to standard output. In this case, command, which simply prints text files to standard output. In this case, tac tac prints the text files to standard output with lines in reverse order. prints the text files to standard output with lines in reverse order.
Example Suppose file1 file1 contains: contains: 1one 2two 3three Then the command: $tacfile1 yields as output: 3three 2two 1one
Name tail Syntax tail[options][files]
Description Print the last few lines of one or more files files (the "tail" of the file or files). When more than one file is specified, a header is printed at the beginning of each file, and each is listed in succession. (the "tail" of the file or files). When more than one file is specified, a header is printed at the beginning of each file, and each is listed in succession.
Frequently used options -cn This option prints the last n n bytes, or if bytes, or if n n is followed by is followed by k k or or m m, the last n n kilobytes or megabytes, respectively. kilobytes or megabytes, respectively.
-nm Prints the last m m lines. The default is 10. lines. The default is 10.
-f Continuously display a file as it is actively written by another process ("follow" the file). This is useful for watching logfiles as the system runs.
Name tr Syntax tr[options][string1[string2]]
Description Translate characters from string1 string1 to the corresponding characters in to the corresponding characters in string2 string2. tr tr does does not not have file arguments and therefore must use standard input and output. have file arguments and therefore must use standard input and output.
Note that string1 string1 and and string2 string2 should contain the same number of characters since the first character in should contain the same number of characters since the first character in string1 string1 will be replaced with the first character in will be replaced with the first character in string2 string2 and so on. and so on.
Either string1 string1 or or string2 string2 can contain several types of special characters. Some examples follow, although a full list can be found in the can contain several types of special characters. Some examples follow, although a full list can be found in the tr tr manpage. manpage.
a-z All characters from a a to to z z.
A backslash () character.
nnn The ASCII character with the octal value nnn nnn.
x Various control characters:abell bbacks.p.a.ce fformfeed nnewline rcarriagereturn thorizontaltab vverticaltab Frequently used options -c Use the complement of (or all characters not not in) in) string1 string1.
-d Delete characters in string1 string1 from the output. from the output.
-s Squeeze out repeated output characters in string1 string1.
Example 1 To change all lowercase characters in file1 file1 to uppercase, use: to uppercase, use: $catfile1|tra-zA-Z or: $catfile1|tr'[:lower:]''[:upper:]'
Example 2 To suppress repeated whites.p.a.ce characters from file1 file1: $catfile1|tr-s'[:blank:]'
Example 3 To remove all non-printable characters from file1 file1 (except the newline character): (except the newline character): $catfile1|tr-dc'[:print:]n'
Name unexpand Syntax unexpand[options][files Description Convert s.p.a.ces to Tabs. This command performs the opposite action of expand expand. By default, Tab stops are a.s.sumed to be every eight s.p.a.ces.
Frequently used options -a Convert all s.p.a.ces, not just leading s.p.a.ces. Normally unexpand unexpand will work only on s.p.a.ces at the beginning of each line of input. Using the will work only on s.p.a.ces at the beginning of each line of input. Using the -a -a option causes it to replace s.p.a.ces anywhere in the input. option causes it to replace s.p.a.ces anywhere in the input.NoteThis behavior of unexpand unexpand differs from differs from expand expand. By default, expand expand converts all Tabs to s.p.a.ces. It requires the converts all Tabs to s.p.a.ces. It requires the -i -i option to convert only leading s.p.a.ces. option to convert only leading s.p.a.ces.
-t number number Specify Tab stops in place of the default 8.
Name uniq Syntax uniq[options][input[output]]
Description Writes input input (or (or stdin stdin) to output output (or (or stdout stdout), eliminating adjacent duplicate lines.
LPI Linux Certification in a Nutshell Part 6
You're reading novel LPI Linux Certification in a Nutshell Part 6 online at LightNovelFree.com. You can use the follow function to bookmark your favorite novel ( Only for registered users ). If you find any errors ( broken links, can't load photos, etc.. ), Please let us know so we can fix it as soon as possible. And when you start a conversation or debate about a certain topic with other people, please do not offend them just because you don't like their opinions.
LPI Linux Certification in a Nutshell Part 6 summary
You're reading LPI Linux Certification in a Nutshell Part 6. This novel has been translated by Updating. Author: Adam Haeder already has 1014 views.
It's great if you read and follow any novel on our website. We promise you that we'll bring you the latest, hottest novel everyday and FREE.
LightNovelFree.com is a most smartest website for reading novel online, it can automatic resize images to fit your pc screen, even on your mobile. Experience now by using your smartphone and access to LightNovelFree.com
- Related chapter:
- LPI Linux Certification in a Nutshell Part 5
- LPI Linux Certification in a Nutshell Part 7