Working with Files - Paiet/Tech-Journal-for-Everything GitHub Wiki

  • Viewing File Contents
    • cat
    • more
    • less
    • tail
    • head
  • Creating Files
    • touch
  • Expansion
    • Useful for working with multiple files
    • touch memo{1,2,3,4,5}
    • touch {John,Bill,Sally}-{Breakfast,Lunch,Dinner}
    • Ranges can be used
      • touch memo{6..9}
  • Redirection
    • >
      • Redirects standard output (stdout)
      • ls -lh | sort > list.txt
    • 2>
      • Redirects standard error (stderr)
    • &>
      • Redirects stdout and stderr
    • >>
      • Appends output
    • <
      • Redirects input
      • sort -r < list.txt
  • Copying Files
    • cp file.dat new_file.dat
    • cp file.dat TempDir/
    • cp file.dat TempDir/file2.dat
    • cp -R TempDir NewDir
  • Moving Files
    • mv document.odt important/purchases/
    • mv document.odt washer-order.odt
  • Deleting Files
    • rm junk.txt
    • rm -r JunkDir
    • rm -rf JunkDir