"Bash"의 두 판 사이의 차이

ph
이동: 둘러보기, 검색
59번째 줄: 59번째 줄:
  
 
[https://www.cyberciti.biz/faq/find-linux-what-running-on-port-80-command/]
 
[https://www.cyberciti.biz/faq/find-linux-what-running-on-port-80-command/]
 +
 +
 +
 +
==read from file or stdin==
 +
while read line
 +
do
 +
  echo "$line"
 +
done < "${1:-/dev/stdin}”
 +
<code>${1:-…}</code> takes <code>$1</code> if defined otherwise the file name of the standard input of the own process is used
 +
 +
[http://stackoverflow.com/a/7045517/766330]
 +
 +
 +
 +
== ==

2017년 4월 4일 (화) 04:06 판

manual, refs


bash expansion : ranges

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

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

For more information, refer wiki.bash-hackers.org.


redirection

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


string : $''

$ # 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/\'//‘

[1]


or

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

ref. expressions used with if


extract tar archive from stdin

use - as the input file

cat largefile.tgz.aa largefile.tgz.ab | tar zxf -

[2]


find out what is using TCP port 80

# netstat -tulpn | grep :80

-p : You should be root

[3]


read from file or stdin

while read line 
do
  echo "$line"
done < "${1:-/dev/stdin}”

${1:-…} takes $1 if defined otherwise the file name of the standard input of the own process is used

[4]