Unix For Testers
Unix System Architecture
Unix File System Structure
Absolute and Relative Path
Basic Unix Commands
cal command in Unix
who command in Unix
date command in Unix
clear command in Unix
more command in Unix
whoami command in Unix
uname command in Unix
man command in Unix
echo command in Unix
Unix File System Commands
ls command in Unix
cat command in Unix
cp command in Unix
mv command in Unix
pwd command in Unix
cd command in Unix
mkdir command in Unix
rmdir command in Unix
rm command in Unix
touch command in Unix
dirname command in Unix
tar command in Unix
Unix Links(ln)
Hard Link
Soft Link
Regular Expressions
Basic Regular Expressions
Interval Regular Expressions
Pipes and Filters
Unix Text Processing Commands
cmp command in Unix
diff command in Unix
comm command in Unix
cut command in Unix
Paste command in Unix
head command in Unix
tail command in Unix
wc command in Unix
sort command in Unix
grep command in Unix
Process Related Command
top command in Unix
ps command in Unix
nice command in Unix
Kill command in Unix
nohup command in Unix
time command in Unix
File Tranfer Commands in Unix
file transfer using scp command
file transfer using rlogin command
file transfer using telnet command
ssh(Secure Shell) command in Unix
ftp file transfer command
sftp file transfer command
chmod command in Unix
File Permission and File Security in Unix
Pipes and Filters in Unix / Linux
Pipes and filters in Unix are the set of commands that take input from standard input stream i.e. stdin, perform some operations and write output to standard output stream i.e. stdout. Filters and pipes are used mostly with grep command, more command and sort command. Â
In this article, we will cover below topics:
Pipes in Unix
Redirecting input/output to a named file, two commands can be connected together so that the output from one program becomes the input of the next program using pipe.
When a pipe is established between two commands, the output of first command is redirected to standard input of second command.
You can achieve this by using a vertical bar (|) on the command line between two commands represents pipe.
Â
SYNTAX:
$command 1|command 2
Filters in Unix
Any program that can take input from standard input and write results to standard output (after processing) is called filter.
The stdin and stdout can be managed as per preferences using redirection and pipes. Common filter commands are: grep, sort , more etc.
-
-
grep
-
It is a pattern or expression searching command.
Prints found matches.
Syntax:
$grep[options] "pattern to be matched" [filename ]
Example:
$grep 'hello' testFile.txt
Output : searches hello in the testFile.txt and outputs/returns the lines containing ‘hello’.
Grep command can also be used with meta-characters:
Example:
$grep 'test' *
Output : it searches for ‘test’ in all the files and directories.
* is a meta-character and returns matching 0 or more preceding characters
refer here for more examples on grep command.
-
-
sort Unix command
-
-
- Ordered arrangement.
- sorts lines of text alphabetically or numerically, default sorting is alphabetical
SYNTAX:
$sort[options] filename
OPTION USE
-d : dictionary order sort
-n : arithmetic/numeric order
-r : reverse order
-k : n Sorts on field n
-b : ignore leading blanks
-m: Merge (not sort)
Example:
$sort file1.txt $sort -n file2.txt
-
-
more Unix command
-
-
- customize the display content of the file.
- It displays the text file contents on the terminal with paging controls.
You can use below key controls with more command:
-
- You can display next line by pressing the enter key
- To bring up next screen, press spacebar
- If you want to move to the next file, press n
- To quit, press q.
SYNTAX:
$more[options] filename
Example:
$cat file1.txt | more
After executing above command, more command is displayed at the bottom of the screen. Use keyboard inputs to move through the text.
Recommended Articles:
Unix For Testers
Unix System Architecture
Unix File System Structure
Absolute and Relative Path
Basic Unix Commands
cal command in Unix
who command in Unix
date command in Unix
clear command in Unix
more command in Unix
whoami command in Unix
uname command in Unix
man command in Unix
echo command in Unix
Unix File System Commands
ls command in Unix
cat command in Unix
cp command in Unix
mv command in Unix
pwd command in Unix
cd command in Unix
mkdir command in Unix
rmdir command in Unix
rm command in Unix
touch command in Unix
dirname command in Unix
tar command in Unix
Unix Links(ln)
Hard Link
Soft Link
Regular Expressions
Basic Regular Expressions
Interval Regular Expressions
Pipes and Filters
Unix Text Processing Commands
cmp command in Unix
diff command in Unix
comm command in Unix
cut command in Unix
Paste command in Unix
head command in Unix
tail command in Unix
wc command in Unix
sort command in Unix
grep command in Unix
Process Related Command
top command in Unix
ps command in Unix
nice command in Unix
Kill command in Unix
nohup command in Unix
time command in Unix
File Tranfer Commands in Unix
file transfer using scp command
file transfer using rlogin command
file transfer using telnet command
ssh(Secure Shell) command in Unix
ftp file transfer command
sftp file transfer command
chmod command in Unix
File Permission and File Security in Unix