less than 1 minute read

1. I/O redirection

1-1 > and >>

  • >: overwrite
command > filename
  • >>: append
command >> filename

* 0: stdin, 1: stdout, 2: stderr

* if make to dispose output, redirect to /dev/null

  • <: using the contents of file, run command.
command < filename



2. pipeline

command1 | command2

command1 output goes into command2 input(filename)



3. sort

sort filename
optionexampleexplain
-ksort -k 1,2 data.txtsorting contents in data.txt following key 1.
if key 1 value same, follow key 2
-nsort -n data.txtsorting contents in data.txt by its numeric value
-rsort -r data.txtsorting contents in data.txt in reverse



4. find

find start_dir search_option command
  • search_option
optionexampleexplain
-namefind -name *.out commandfind file named *.out
-sizefind -size 0 commandfind 0 byte size file
  • command
optionexampleexplain
-execfind -name *.out -exec rm -i {} ';'find file named *.out and execute rm -i searched_file
-printfind -size 0 -printfind 0 byte size file and print

   * -exec using found file, {}

   * -exec must end with char ; (escape sequence \;, single char ';')

Categories:

Updated:

Leave a comment