Manipulating Commands in Linux
From the shell's point of view, there are three kinds of information in linux:
standard input
sstandard output
standard error
Standard input is the information that a user enters from the keyboard for the linux shell to use, such as commands and filenames.
Standard output is essentially the information shell prints on the screen after evaluating a user's commands.
Standard error is the information that indicates that something has gone wrong.
Pipes
Pipes
A pipe is the ( | ) symbol. It is used to connect the standard output of one command to the standard input of another command. Essentially, it allows a user to string commands together.
eg: cat filename | less
Using Redirection
Redirection means changing where standard input comes from or where the standard output goes.
For redirection the symbol used in Linux is ">".Placing ">" after the any command utility then it redirects its output to the file name following the symbol.
eg: cat filename > newfile (the "newfile" will save the output of the file "filename")
Appending Standard Output
The symbol >> appends standard output. This means it adds the standard output to the end of a file, rather than over-writing the file.
eg:less filename >> newfile (the "newfile" will be appended with the out put of "filename")
Comparing two files
To compare two files such as "actual file" and the "modified file" of the actual one,and to find out the difference between the two files the "diff" command is used. "diff" compares text files line-by-line and reports the differences to standard output.
eg: diff file1 file2