names=()
names=("Bob" "Peter" "$USER" "Big Bad John")
names=([0]="Bob" [1]="Peter" [20]="$USER" [21]="Big Bad John")
names[0]="Bob"
photos=(~/"My Photos"/jpg)
files=()
declare -a myfiles='([0]="/home/a/bashrc" [1]="billing codesxlsx" [2]="helloc")'
declare -p myfiles
printf '%s\n' "${myfiles[@]}"
bash里面的字典叫做关联数组,字典其实和数组类似,不同点在于,字典的key是字符串,并且遍历时是随机的。
注意事项:
#!/bin/bashfunc()
{
START=$1
END=$2
awk -vstartt="$START" -vendt="$END" 'BEGIN{
startm=mktime(gensub("-", " ", "g", startt) " 0 0 0")
endtm=mktime(gensub("-", " ", "g", endt) " 0 0 0")
for(i=startm;i<=endtm;i+=360024)
print strftime("%Y-%m-%d", i)
}'
}
func "2013-10-1" "2013-10-5"
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)