[번역] Bash 명령어 가이드
Bash는 상호적인 라인 인터프리터 또는 쉘입니다. 저는 간단한 쉘 명령어 사용법과 그것들이 무엇인지 공유하려고 합니다. 저는 시간 절약을 위한 목적으로 이 목록을 작성했습니다. 왜냐하면, GUI 없이는 모든 트랜잭션은 마우스 사용없이 빠르게 움직이기 때문입니다. 이 글은 제 다음 글 iOS 개발자를 위한 Bash 스크립트 가이드를 위한 가이드입니다.
ls
현재 작업 중인 디렉토리의 폴더와 파일 이름을 나열합니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ls -a # 숨겨진 파일을 포함한 모든 파일을 나열합니다. | |
$ ls -A # 숨겨진 파일을 포함하고 최상위 디렉토리를 제외한 모든 파일을 나열합니다. | |
$ ls -F # 항목에 인디케이터(*/=>@| 중 하나)를 추가합니다. | |
$ ls -S # 파일 크기에 따라 정렬합니다. | |
$ ls -al # 같은 디렉토리에 있는 모든 파일의 목록을 제공합니다. | |
$ ls -l # 긴 형태를 사용합니다. | |
$ ls -nl # 사용자 ID가 포함된 긴 형태를 사용합니다. | |
$ ls -c # ctime(마지막 변경 시간)으로 정렬합니다. |
man
시스템 참고 메뉴얼을 보기 위해 사용되는 인터페이스입니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ man ls # 명령을 실행하는데 사용할 수 있는 모든 옵션을 보여줍니다. | |
$ man -V --version # 버전 정보를 표시합니다. | |
$ man -c # ~/.manpath 파일의 기본 설정이 아닌 설정 파일을 사용합니다. | |
$ man -d # 디버깅 정보를 표시합니다. |
env
현재 사용자의 환경 변수 목록을 반환합니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ env |
chmod
파일이나 디렉토리의 권한을 변경합니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ chmod 777 # 모든 사용자가 읽고, 쓰고, 실행할 수 있습니다. 예) chmod 777 my_file | |
$ chmod 755 # 다른 사용자가 읽고 실행할 수 있지만 변경은 주 사용자만 가능합니다. | |
$ chmod 777 # 주 사용자만이 읽고, 쓰고, 실행할 수 있습니다. |
chwon
파일과 디렉토리의 소유권을 변경합니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ chown --help && chown --version |
PATH
콜론으로 구분된 디렉토리 목록을 저장합니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ echo $PATH |
grep
파일에서 패턴과 매칭되는 라인을 찾고 결과를 반환합니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ grep "keyword" file.tx # 하나의 파일에서 주어진 문자열로 찾습니다. | |
$ grep -i "keyword" file.tx # 대소문자 구별없이 찾습니다. | |
$ grep -R "keyword" file.tx # 디렉토리의 모든 파일을 찾고 찾은 결과를 포함한 라인과 파일 이름을 결과로 반환합니다. |
awk
특정 라인을 추출합니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ awk {keyword} file.tx |
open
파인더에서 현재 폴더를 엽니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ open . |
chgrp
파일과 디렉토리의 그룹을 변경합니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ chgrp groupname file.txt |
pwd
작업 중인 디렉토리 이름을 출력합니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ pwd |
cd
현재 작업 중인 디렉토리를 변경합니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cd / # 루트 디렉토리로 이동합니다. | |
$ cd .. # 부모 디렉토리로 이동합니다. | |
$ cd # 파라미터 없이 사용하는 경우에 사용자 홈 디렉토리로 이동합니다. | |
$ cd ~root # '~' 뒤에 사용자 이름이 주어지면 그 사용자의 홈 디렉토리로 이동합니다. |
HOME
홈 디렉토리 경로를 보여줍니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ echo $HOME |
nano
키보드 입력만 받는 커맨드 라인 에디터입니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ nano myscript.sh |
find
파일과 디렉토리를 검색합니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ find directory -name filename # 이름으로 파일을 찾습니다. | |
$ find directory -cnewer file # 파라미터로 준 파일 보다 더 최근에 수정된 파일들을 검색합니다. | |
$ find directory -amin n # n분 전 마지막 접근한 파일을 찾습니다. | |
$ find directory -cmin n # n분 전 마지막 변경된 파일을 찾습니다. | |
$ find directory -atime n # n일 전 마지막 접근한 파일을 찾습니다. | |
$ find directory -mtime n # n일 전 마지막 변경된 파일을 찾습니다. | |
$ find directory -ctime n # n일 전 마지막 변경된 파일을 찾습니다. | |
$ find directory -print # 찾은 파일의 경로를 표시합니다. | |
$ find directory -exec # 검색 결과에 따라 명령어를 실행합니다. | |
# mtime vs atime vs ctime : https://www.quora.com/What-is-the-difference-between-mtime-atime-and-ctime |
mkdir
명령어로 디렉토리를 생성합니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ mkdir folder # folder라는 이름을 가진 디렉토리를 생성합니다. |
mv
파일이나 디렉토리를 이동시킵니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ mv -i source # 이미 존재하는 파일을 덮어쓰기 전에 안내를 해줍니다. | |
$ mv -f source # 안내 없이 이미 존재하는 파일은 덮어씁니다. | |
$ mv -n source # 이미 존재하는 파일은 절대 덮어쓰지 않습니다. | |
$ mv -v source # 옮기기 전 경로와 옮긴 후 경로를 출력합니다. |
rm
파일이나 디렉토리를 삭제합니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ rm -f file # 삭제하는데 묻지 않습니다. 또한 존재하지 않는 파일에 대한 정보도 제공하지 않습니다. | |
$ rm -i file # 파일을 삭제하기 전에 안내합니다. | |
$ rm -r directory # 디렉토리와 하위 디렉토리의 모든 내용물을 삭제합니다. | |
$ rm -v file # 삭제 과정에 대한 정보를 제공합니다. |
rmdir
디렉토리를 삭제합니다. 폴더가 비어 있을 경우에만 작동합니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ rmdir -p directoryname |
touch
파일 내용에 아무런 변화 없이 파일을 생성하거나 엽니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ touch -a file # 접근 시간을 업데이트합니다. | |
$ touch -c file # 파일이 존재하지 않으면 생성합니다. | |
$ touch -m file # 변경 시간을 업데이트합니다. | |
$ touch -t file # 주어진 시간대로 접근 시간을 변경합니다. |
cat
파일의 내용물을 보여줍니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat -n file # 화면에 주어진 숫자의 라인만큼 파일 내용물을 보여줍니다. |
wc
파일의 개행, 단어, 바이트 수를 출력합니다. 파일이 여러개일 경우 합쳐서 출력합니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ wc -l file # 행의 수를 반환합니다. | |
$ wc -m file # 문자 수를 반환합니다. | |
$ wc -w file # 단어 수를 반환합니다. |
head
파일의 첫부분을 출력합니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ head file # 첫 몇 줄을 보여줍니다. |
tail
파일의 뒷부분을 출력합니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ tail file # 마지막 몇 줄을 보여줍니다. |
more
화면 단위로 파일의 내용물을 출력합니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ more file |
less
위아래 방향 뿐 아니라 아래위 방향 이동도 지원합니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ less file |
nl
라인마다 번호를 추가해서 보여줍니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ nl file |
끝입니다. 읽어주셔서 감사합니다. 당신의 생산성을 높이는데 도움이 되었으면 좋겠습니다.
이 글은 Bash Commands Guide를 번역했습니다.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home