previous | start | next

Using cat to Read/Change File Contents

Read input from a file, say in.txt, and display on standard output:

        cat in.txt
     

Read input from keyboard (standard input) and display on standard output, type ctrl-d to terminate input.

        $ cat 
          hello, world typed input
          hello, world output from cat
          goodbye      typed input
          goodbye      output from cat
          ctrl-d       signal end of input to cat
     

Read input from key board (standard input) and redirect output to a file, say out.txt:

        $ cat >out.txt
          hello, world  typed input
          goodbye       typed input
          ctrl-d        signal end of input to cat; closes file out.txt
     

Note: Redirecting output to out.txt will first delete the contents of out.txt if it already exists.



previous | start | next