|
Software
Files File Redirection
Directory Shell Features/Different types of shell Changing your shell Networking Reference
|
File RedirectionFile Redirection is the special commands in Unix that instruct the computer to read from a file, write to a file, or even append information to an existing file.When you issue a Unix command like date, the output of the command goes to what is called Standard output. Type at the prompt %date output will look like Thu Oct 11 16:03:06 EDT 2001 Each of these acts can be accomplished by placing a file-redirection command in a regular command line: < redirects input : For example to run prog1 but read data from a file input_file instead of the keyboard, you would type prog1<input_file > redirects output : For example to run prog1 and write data to output_file instead of the screen, you would type prog1>output_file Above two commands can be combined as follows prog1 < input_file > output_file >> redirects output and appends the information to the existing file To show application of above commands, here are the few examples :
Removing the duplicate lines using function uniq
%tail -1 testme > lastline %cat lastline lastline lastline lastline > newtest2 %cat newtest2 News/ abc.txt testme News/ abc.txt testme News/ abc.txt testme News/ abc.txt testme Now you can see what uniq does %uniq newtest2 News/ abc.txt testme
|