본문 바로가기

Unix & Linux/명령어

유용한 명령어 - A

alias : 명령어를 간단하게 줄여사용

ex) alias ll='ls -alrt'

unalias: alias 삭제

* '\'를 붙여 사용하거나 명령어의 절대경로를 사용하여 명령어 입력하면 alias무시됨

 

apropos : 명령어 검색

* man -k 와 동일

 

arch : cpu 타입조회

 

arp : 연결시스템 mac주소 확인

 

at : 명령어 또는 스크립트 실행 예약

 

awk : 패턴검색

ex) awk /mail/ /etc/passwd -> passwd파일에서 'mail'이 포함된 라인을 출력

awk -F: /mail/'{print $1}' /etc/passwd -> 'mail'이 포함된 라인중 ':'을 구분자로 첫번째 토큰 출력

awk시스템변수 

 $0  refers to the entire line
 $n  The fields are denoted $1, $2, ...
 CONVFMT  conversion format used when converting numbers (default %.6g)
 FS  regular expression used to separate fields; also settable by option -Ffs.

 NF

 number of fields in the current record

 NR

 ordinal number of the current record

 FILENAME

 the name of the current input file

 RS

 input record separator (default newline)

 OFS

 output field separator (default blank)

 ORS

 output record separator (default newline)

 OFMT

 output format for numbers (default %.6g)

 SUBSEP

 separates multiple subscripts (default 034)

 ARGC

 argument count, assignable

 ARGV

 argument array, assignable; non-null members are taken as filenames

 ENVIRON

 array of environment variables; subscripts are names
 FNR  ordinal number of the current record in the current file

ex) awk /mail/'{print NR,$0, NF}' /etc/passwd

 

awk 함수

The  mathematical  functions  exp, log, sqrt, sin, cos, and atan2 are built in

length / rand / srand / int / substr(d,m,n) / index(s,t) / match(s,r) /

split(s,a,fs) / sub(r,t,s) / gsub / sprintf(fmt,expr,...) / system(cmd) /

tolower(str) / toupper(str)

ex)

       length($0) > 72
              Print lines longer than 72 characters.

 

       { print $2, $1 }
              Print first two fields in opposite order.

 

       BEGIN { FS = ",[ \t]*|[ \t]+" }
             { print $2, $1 }
              Same, with input fields separated by comma and/or blanks and tabs.

 

            { s += $1 }
       END  { print "sum is", s, " average is", s/NR }
              Add up first column, print sum and average.

 

       /start/, /stop/
              Print all lines between start/stop pairs.

 

       BEGIN     {    # Simulate echo(1)
            for (i = 1; i < ARGC; i++) printf "%s ", ARGV[i]
            printf "\n"
            exit }

 

 

 

'Unix & Linux > 명령어' 카테고리의 다른 글

find 명령어  (0) 2013.10.03
netstat  (0) 2012.11.02
whereis 명령어  (0) 2011.06.17
rm 명령어  (0) 2011.06.17
[UNIX/Linux] history 명령어  (0) 2011.05.06