반응형


cat hello.txt : hello.txt 파일 내용을 보여줍니다.
more hello.txt : hello.txt 내용을 spacebar 를 이용하여 화면에 한페이지씩 보여줍니다. more page
less hello.txt : hello.txt 내용을 한줄 한줄 읽어 내려갈 수 있으며 spacebar 한페이지씩 보여줍니다. move a line by line
wc hello.txt : hello.txt 단어, 라인, word count
wc -l hello.txt : hello.txt 라인 카운트를 보여줍니다. no. of line
wc -c hello.txt : hello.txt 파일 크기를 보여줍니다. (byte)
wc -m hello.txt : hello.txt 글씨 카운트를 해줍니다. (character)
head -3 hello.txt : hello.txt 내용 중 첫 3 줄을 보여줍니다.
tail -3 hello.txt : hello.txt 내용 중 마지막 3줄을 보여줍니다.


history : 현재까지 실행했던 모든 명령어들을 보여줍니다.


Redirection

출력의 경로수정


cal : 달력을 출력합니다.


     August 2014   
Su Mo Tu We Th Fr Sa
                1  2
 3  4  5  6  7  8  9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31


cal > output.txt : 달력을 출력한 뒤 내용을 outpu.txt 파일에 담습니다.

cat output.txt : output.txt 파일 내용을 화면에 출력합니다.


     August 2014   
Su Mo Tu We Th Fr Sa
                1  2
 3  4  5  6  7  8  9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31


Pipeline

여러개의 명령어를 순차적으로 실행하여 결과값을 출력합니다.


cat /etc/passwd | tail -3


vmplayer:x:502:503:vmplayer:/images/vmplayer:/usr/bin/feit-windows-A2013.sh
oprofile:x:16:16:Special user account to be used by OProfile:/home/oprofile:/sbin/nologin
vmuser:x:503:504:vmuser:/var/lib/vmuser:/bin/bash

bash-4.1$ who
11776352 tty3         2014-08-13 12:06 (:0)
11776352 pts/0        2014-08-13 12:10 (:0.0)


bash-4.1$ who | head -1
11776352 tty3         2014-08-13 12:06 (:0)


bash-4.1$ who | grep 11776352
11776352 tty3         2014-08-13 12:06 (:0)
11776352 pts/0        2014-08-13 12:10 (:0.0)

bash-4.1$ cat /etc/passwd | cut -d: -f1,5


bash-4.1$ who
11776352 tty3         2014-08-13 12:06 (:0)
11776352 pts/0        2014-08-13 12:10 (:0.0)


bash-4.1$ who | cut -d' ' -f1
11776352
11776352
bash-4.1$ who | cut -d' ' -f1 | sort
11776352
11776352
bash-4.1$ who | cut -d' ' -f1 | sort | uniq
11776352
bash-4.1$ who | cut -d' ' -f1 | sort | uniq >username.txt

bash-4.1$ who | awk '{ print $3}'
2014-08-13
2014-08-13


bash-4.1$ who | awk '{ print $1, $3}'
11776352 2014-08-13
11776352 2014-08-13

bash-4.1$ ls /bin | wc -l
131


bash-4.1$ ls /bin | head -1
alsaunmute


bash-4.1$ ls /bin | head -10
alsaunmute
arch
awk
basename
bash
cat
cgclassify
cgcreate
cgdelete
cgexec


bash-4.1$ ls /bin | head -79 | tail -1
netstat


계산식
x=$((2+2))
echo x is $x //prints out the result




반응형

+ Recent posts