- Standard I/P and Standard O/P
- I/P from standard input i.e. terminal and O/P to standard O/P i,e, terminal
[shell_test@localhost ~]$ ls -l
total 32
drwxr-xr-x. 2 shell_test shell_test 4096 2009-11-09 06:29 Desktop
drwxr-xr-x. 2 shell_test shell_test 4096 2009-11-09 06:29 Documents
drwxr-xr-x. 2 shell_test shell_test 4096 2009-11-09 06:29 Download
drwxr-xr-x. 2 shell_test shell_test 4096 2009-11-09 06:29 Music
drwxr-xr-x. 2 shell_test shell_test 4096 2009-11-09 06:29 Pictures
drwxr-xr-x. 2 shell_test shell_test 4096 2009-11-09 06:29 Public
drwxr-xr-x. 2 shell_test shell_test 4096 2009-11-09 06:29 Templates
drwxr-xr-x. 2 shell_test shell_test 4096 2009-11-09 06:29 Videos
[shell_test@localhost ~]$ - Redirecting I/P and O/P
-
Redirecting O/P to a file i.e. other than terminal
- Using ‘>’
- Append more results using ‘>>’
[shell_test@localhost ~]$ ls -l > listoffiles
[shell_test@localhost ~]$ cat listoffiles
total 32
drwxr-xr-x. 2 shell_test shell_test 4096 2009-11-09 06:29 Desktop
drwxr-xr-x. 2 shell_test shell_test 4096 2009-11-09 06:29 Documents
drwxr-xr-x. 2 shell_test shell_test 4096 2009-11-09 06:29 Download
-rw-rw-r–. 1 shell_test shell_test 0 2009-11-14 14:35 listoffiles
drwxr-xr-x. 2 shell_test shell_test 4096 2009-11-09 06:29 Music
drwxr-xr-x. 2 shell_test shell_test 4096 2009-11-09 06:29 Pictures
drwxr-xr-x. 2 shell_test shell_test 4096 2009-11-09 06:29 Public
drwxr-xr-x. 2 shell_test shell_test 4096 2009-11-09 06:29 Templates
drwxr-xr-x. 2 shell_test shell_test 4096 2009-11-09 06:29 Videos
[shell_test@localhost ~]$[shell_test@localhost ~]$ ls >> listoffiles
[shell_test@localhost ~]$ cat listoffiles
total 32
drwxr-xr-x. 2 shell_test shell_test 4096 2009-11-09 06:29 Desktop
drwxr-xr-x. 2 shell_test shell_test 4096 2009-11-09 06:29 Documents
drwxr-xr-x. 2 shell_test shell_test 4096 2009-11-09 06:29 Download
-rw-rw-r–. 1 shell_test shell_test 0 2009-11-14 14:35 listoffiles
drwxr-xr-x. 2 shell_test shell_test 4096 2009-11-09 06:29 Music
drwxr-xr-x. 2 shell_test shell_test 4096 2009-11-09 06:29 Pictures
drwxr-xr-x. 2 shell_test shell_test 4096 2009-11-09 06:29 Public
drwxr-xr-x. 2 shell_test shell_test 4096 2009-11-09 06:29 Templates
drwxr-xr-x. 2 shell_test shell_test 4096 2009-11-09 06:29 Videos
Desktop
Documents
Download
listoffiles
Music
Pictures
Public
Templates
Videos
[shell_test@localhost ~]$ -
Getting I/P from files
- use ‘<'
[shell_test@localhost ~]$ wc -l listoffiles
19 listoffiles
[shell_test@localhost ~]$ - Pipes
-
Pipes are used to redirect O/P of one command to I/P of other command
see following example-
[shell_test@localhost tmp]$ who > users
[shell_test@localhost tmp]$ cat users
gpvprasad tty1 2009-11-18 21:38 (:0)
gpvprasad pts/0 2009-11-18 22:06 (:0.0)
[shell_test@localhost tmp]$ wc -l users
2 users
[shell_test@localhost tmp]$
which can be executed in single line using ‘|’
-
[shell_test@localhost tmp]$ who | wc -l
2
[shell_test@localhost tmp]$
-
[shell_test@localhost tmp]$ who > users
-
Most Unix system commands take input from your terminal and send the resulting output back to your terminal. A command normally reads its input from a place called standard input, which happens to be your terminal by default. Similarly, a command normally writes its output to standard output, which is also your terminal by default.