2014. 8. 19. 15:08

메타캐릭터

 

 

Tilde(~) : 홈디렉토리 의미

 

cd ~ / cd : 홈디렉토리로 이동, ~ 생략가능

cd ~oracle  / cd ~사용자계정  : 특정사용자의 홈디렉토리 이동

 

*(아스테리크) : 모든

? : 글자

* 글자 수의 제한 없음, ? 1개면 하나에 글자만 가능

 

[] : 대괄호 사이의 모든 글자. 범위지정

rm –f [abc].sh  : 파일명이 a.sh 혹은 b.sh 혹은 c.sh 파일을 지워라

rm –f [ab][0-5].txt : 파일명이 1번째 글자는 a 혹은 b, 두번째 글자는 0-5사이에 있는 txt파일을 지워라

대괄호 안에 [abc] [bca] 같음, 순서는 상관없음

 

[root@server117 test]# ls -al

total 12

drwxr-xr-x  2 root root 4096 Aug 19 20:55 .

drwxr-x--- 16 root root 4096 Aug 19 20:31 ..

-rw-r--r--  1 root root    0 Aug 19 20:55 abcd.sh

-rw-r--r--  1 root root    0 Aug 19 20:55 abs.sh

-rw-r--r--  1 root root    0 Aug 19 20:55 ag.sh <-삭제됨

-rw-r--r--  1 root root    0 Aug 19 20:55 a.sh

-rw-r--r--  1 root root    0 Aug 19 20:55 b.sh

-rw-r--r--  1 root root    0 Aug 19 20:55 c.sh

[root@server117 test]# rm -f [ab][a-h].sh 글자

[root@server117 test]# ls -al

total 12

drwxr-xr-x  2 root root 4096 Aug 19 20:57 .

drwxr-x--- 16 root root 4096 Aug 19 20:31 ..

-rw-r--r--  1 root root    0 Aug 19 20:55 abcd.sh

-rw-r--r--  1 root root    0 Aug 19 20:55 abs.sh

-rw-r--r--  1 root root    0 Aug 19 20:55 a.sh

-rw-r--r--  1 root root    0 Aug 19 20:55 b.sh

-rw-r--r--  1 root root    0 Aug 19 20:55 c.sh

 

Escape Character 탈출문자

* 의미 : 모든

\* 의미 : 단순히 문자로의 *

 

[root@server117 test]# touch a.sh b.sh \*.sh

[root@server117 test]# ls -l

total 0

-rw-r--r-- 1 root root 0 Aug 19 20:55 abcd.sh

-rw-r--r-- 1 root root 0 Aug 19 20:55 abs.sh

-rw-r--r-- 1 root root 0 Aug 19 21:12 a.sh

-rw-r--r-- 1 root root 0 Aug 19 21:12 b.sh

-rw-r--r-- 1 root root 0 Aug 19 20:55 c.sh

-rw-r--r-- 1 root root 0 Aug 19 21:12 *.sh

[root@server117 test]# rm -f \*.sh

[root@server117 test]# ls -l

total 0

-rw-r--r-- 1 root root 0 Aug 19 20:55 abcd.sh

-rw-r--r-- 1 root root 0 Aug 19 20:55 abs.sh

-rw-r--r-- 1 root root 0 Aug 19 21:12 a.sh

-rw-r--r-- 1 root root 0 Aug 19 21:12 b.sh

-rw-r--r-- 1 root root 0 Aug 19 20:55 c.sh

 

쉘 메타캐릭터를 문자로 인식하고 싶으면

! 반드시 !! \을 메타캐릭터 앞에 붙여줘야 함

'OS > linux' 카테고리의 다른 글

dns/ftp 구축시 참고  (0) 2014.08.24
리눅스 dns서버 bind 사용 구축하기  (0) 2014.08.23
8-20일배운것  (0) 2014.08.20
리눅스 설치  (0) 2014.08.20
디스크 관리 명령어  (0) 2014.08.19
Posted by 성장하는yw