-
Notifications
You must be signed in to change notification settings - Fork 0
Shell script
jaeseok.an edited this page Jun 11, 2019
·
8 revisions
- increment(++) 하기
running=$((running + 1))
인자 : parameters
function my_function(){
local value=$1
echo "my_function= ${value}"
}
# call my_function
my_function 5678
결과 전달받기
#!/bin/sh
function my_function(){
local value=$1
echo "my_function= ${value}"
}
# call my_function
result=$(my_function 5678)
echo "my_function [ ${result} ]"
function my_function(){
echo "argv: $1 $2"
return 10
}
# call my_function
my_function "myname" "acepro"
result=$?
echo "my_function [ ${result} ]"
function my_function(){
echo "argv: $1 $2"
eval "$3='result'"
}
# call my_function
result=""
my_function "myname" "acepro" result
echo "my_function [ ${result} ]"
- 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]
not regular expression pattern
${variable//pattern/replacement}
regular expression
if [[ $bpname =~ "BP*" ]]; then
뒤에서 lonngest match = %%, 짧은 match =%, 앞에서 match=#으로 변경
bpname=${file%%.toml}
if [ ! -e genesis -o ! -e genesis.json ];
- json parser
- jq
- 특정 필드는 jq .필드명 으로 출력가능하다
- jq
test