Skip to content

Shell script

jaeseok.an edited this page May 3, 2019 · 8 revisions

bash expression

  • bash associative array(map)
$ declare -A MYMAP     # Create an associative array
$ MYMAP[foo]=bar       # Put a value into an associative array
$ echo ${MYMAP[foo]}   # Get a value out of an associative array
bar
$ echo MYMAP[foo]      # WRONG
MYMAP[foo]
$ echo $MYMAP[foo]     # WRONG
[foo]

simple regular expression with variable

not regular expression pattern
${variable//pattern/replacement} 
regular expression
if [[ $bpname =~ "BP*" ]]; then

substitute variable

뒤에서 lonngest match = %%, 짧은 match =%, 앞에서 match=#으로 변경
bpname=${file%%.toml}

if condition

if [ ! -e genesis -o ! -e genesis.json ];

util

  • json parser
    • jq
      • 특정 필드는 jq .필드명 으로 출력가능하다

test

Clone this wiki locally