Bash

ph
Admin (토론 | 기여)님의 2014년 8월 7일 (목) 13:43 판
이동: 둘러보기, 검색

Bash/manual

$ echo {d..h}
d e f g h

$ echo {d..Z}
d c b a _ ^ ]  [ Z

### cp file1 file2와 같다
$ cat < file1 > file2

$ cut -d: -f1 < /etc/password | sort

### man nice
$ nice


$ # Single quotation in single qoute
$ # http://stackoverflow.com/a/16605140/766330
$ echo \'sdlfkjsldf\' | sed $'s/\'//'
sdlfkjsldf'
$ #   $'string' : this is special.
$ #   below line won't work.
$ #   echo \'sdlfkjsldf\' | sed 's/\'//'


$ # 'or' 
$ if [ -z "$1" ] || [ -z "$2" ]; then
>    echo "Usage: `basename $0` rslt_file target_folder"
> fi


$ # for each line of file
$ # do not use 'cat' & 'foreach'
$ # use 'read'
$ # http://stackoverflow.com/a/1521498/766330 
$ while read line; do
>   echo $line
> done < textfile.txt

expressions used with if