리눅스 프로세스 명령어(linux process command) 2. filtering
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
option | example | explain |
-k | sort -k 1,2 data.txt | sorting contents in data.txt following key 1. if key 1 value same, follow key 2 |
-n | sort -n data.txt | sorting contents in data.txt by its numeric value |
-r | sort -r data.txt | sorting contents in data.txt in reverse |
4. find
find start_dir search_option command
- search_option
option | example | explain |
-name | find -name *.out command | find file named *.out |
-size | find -size 0 command | find 0 byte size file |
- command
option | example | explain |
-exec | find -name *.out -exec rm -i {} ';' | find file named *.out and execute rm -i searched_file |
find -size 0 -print | find 0 byte size file and print |
* -exec
using found file, {}
* -exec
must end with char ;
(escape sequence \;
, single char ';'
)
Leave a comment