Aug 2015 - cat pipe grep redirect

From Jacksonville Linux Users Group
Jump to: navigation, search
  • cat

short for concatenate - used to either view the contents of a file, or concatenate 2 or more files together

  • pipe |

used to link/pipe the output of one command into the input of another command.

  • grep

used to search for a string of characters

  • redirect output >
* cat file1.txt   #this will show the whole file 
* cat bigfile.txt | more  #this will display one page at a time!
* cat file1 file2 > file3  #this will combine file1 and file2 and redirect the output into file3.
* grep string1 file3  #this will search file3 for string1 and display all the results.
* grep string1 file3 > file4  #this will save the results to file4 (overwriting it if it had existed before).
* grep string1 file3 >> file4  #this will append the results to file4 (creating it if it had not existed before).