Previous Table of Contents Next


expr - Evaluate Expression Arguments

$expr arguments

Description:

The expr command evaluates arguments as an expression. Expression tokens must be separated with blanks, and special characters must be escaped. Integer arguments can be preceded by a minus sign to indicate a negative number.

Operators (listed in order of precedence):

exp1 \| exp2 return exp1 if neither null nor 0, else return exp2
exp1 \& exp2 return exp1 if neither null nor 0, else return 0
exp1 \<, \<=, =, !=, \>=, \> exp2 return result of the integer or string comparison
exp1 +, , \*, /, % exp2 return result of the arithmetic operation
exp1 : exp2 return the result on the number of matched characters between exp1 and exp2

grep - Search Files for Patterns

$grep [ options ]  'expression'  [ files ]

Description:

The grep command displays lines from files that match the given limited regular expression.

Options:

–b precede each line with the block number
–c display the number of matching lines
–i ignore case of letters during comparisons
–l display only filenames with matching lines once
–n display the output with line numbers
–s do not display error messages
–v display non-matching lines only
files read standard input if no files are specified

paste - Merge Lines Between Files

$paste file1 file2 . . .
$paste –dlist file1 file2 . . .
$paste –s [ –dlist ] file1 file2 . . .

Description:

The paste command merges corresponding lines from files. Each file is treated as a column or columns of a table and displayed horizontally.

Options:??

–dlist replace tabs with characters from list. If this option is not specified, the newline characters for each file (except for the last file, or if –s is given, the last line) are replaced with tabs. The list can contain these special characters:
\n newline
\t tab
\0 empty string
\\ backslash
–s merge subsequent lines instead of one
files read standard input if file1 or file2 is

sed - Stream Editor

$sed [ –n ] [ –e 'script ' [ –f file ] [ files ]

Description:

The sed command copies files to standard output and edits them according to the given editing commands.

Options:

–e script execute commands in script
–f file get commands from file
–n suppress default output
files read standard input if no files are specified

Command Format:

[address [ ,address ] ] commands [ arguments ] execute commands for each input line that matches address or range of addresses. If commands is preceded by “!”, input lines that do not match the address are used.

Addresses:

If no address is given, all input lines are matched. Two addresses indicate a range.

. current line
$ last line
n nth line
/regular-expression/ regular expression
\n newline

Commands:

The maximum number of addresses is listed in parentheses.

(1)a\ text append the following text to the output
(2)b label branch to the :label command. If label is empty, go to the end of the script.
(2)c\ text change lines
(2)d delete lines
(2)D delete first line of input only
(2)g replace input lines with buffer contents
(2)G append buffer contents to input lines
(2)h replace buffer contents with input lines
(2)H append input lines to buffer contents
(1)i\ text insert the following text
(2)l display input lines
(2)n display input line; read next input line
(2)N append next input line to current line
(2)p display input lines
(2)P display first line of input line only
(1)q quit
(2)r file display contents of file
(2)s/RE/s/flags substitute s for the regular expression RE that matches input lines according to flags. The flags can consist of zero or more of:
n substitute for just the nth occurrence of the regular expression RE (1–512)
g substitute for all occurrences of RE
p display input line if substitution was made
w file append input line to file if substitution made
(2)t label branch to :label command if substitution was made. If label is empty, go to end of script.
(2)w file append input line to file
(2)x exchange input line with buffer contents
(2)y/s1/s2 replace characters in s1 with characters in s2. The lengths of s1 and s2 must be equal.
(2)!cmd execute command for the input lines not selected
(1) = display current line number
(2) { treat commands up to closing } as a group
(0)# interpret rest of input line as comments
(0)#n interpret rest of input line as comments and ignore


Previous Table of Contents Next
1