Linux Command

TIPs 2008. 9. 19. 04:29
mkdir

-p : 많약 부모 디렉토리가 존재하지 않는다면, 부모 디렉토리까지 같이 만들어 준다.


source

: shell 환경등을 파일로부터 읽고 실행
$ source .bash_profile


find

-iname 
: 이름에서 대소문자 구분하지 않음
$ find -iname *cookie*

-maxdepth n
: 최대 n depth 까지만 검색

-mindepth n
: 최소 n depth 이상만 검색

-size n
k (kilobytes), M (megabytes), G (gigabytes), T (terabytes), P (petabytes)
$ find / -size +100M (크기가 100M 이상인 파일 검색)

-mtime n
s (second), m (minute), h (hour), d (day), w (week)
$ find . -mtime +60 (변경된지 60일이 지난 파일 검색)

-path pattern
pathname이 패턴과 일치한다면 True이다.
$ find . -type f -not -path "*.svn*" (경로에 svn을 포함하지 않는 파일)

OPERATORS
( expression )
             This evaluates to true if the parenthesized expression evaluates to true.

! expression
-not expression
             This is the unary NOT operator.  It evaluates to true if the expression is false.

-false  Always false.
-true   Always true.

expression -and expression
expression expression
             The -and operator is the logical AND operator.  As it is implied by the juxtaposition of two expressions it does not have to be specified.  The expression evaluates to true if both expressions are true.  The second expression is not evaluated if the first expression is false.

expression -or expression
             The -or operator is the logical OR operator.  The expression evaluates to true if either the first or the second expression is true.  The second expression is not evaluated if the first expression is true.

$ find . -name "*.js" -and -not -name "dojo.js"
짧게 쓰면, 
$ find . -name "*.js" ! -name "dojo.js"


grep
-v, --invert-match 
: 매칭되지 않는 라인을 선택한다.

-m NUM, --max-count=NUM 
: 파일에서 NUM 매칭 라인을 읽은 후에 멈춘다. 
만약 -c or --count 옵션도 사용되었다면, NUM보다 많은 count를 출력하지 않는다.

-c, --count
: 매칭되는 라인의 count수를 출력한다.

-C NUM, -NUM, --context=NUM
: Print NUM lines of output context (매칭되는 라인 주변 NUM 라인을 같이 출력)

-w, --world-regxp
: 전체 단어를 매칭 시킨다.


dd

bs=BYTES

: read and write BYTES bytes at a time

ibs=BYTES
: read BYTES bytes at a time (defauilt : 512)

obs=BYTES
: write BYTES bytes at a time (default : 512)

count=BLOCKS
: copy only BLOCKS input blocks

# dd if=/dev/zero of=bigfile bs=1K count=1024


cut


-d, --delimiter=DELIM
: use DELIM instead of TAB for field delimiter

-f, --fields=LIST
: select only these fields; also print any line that contains no delimiter character, unless the -s option is specified

$ lspci | cut -d: -f1-3


: