[bash]:BASH中的变量——可先用后定义
一、说明
二、脚本
[wit@test:tmp]$ cat bash_test
#!/usr/bin/env bashfunction do_msg()
{echols -lh .echoecho -e "\t[DO_MSG]#\tHahaha......"# variables(no position): first use , last define.echo -e "\t[DO_MSG]#\t${FILE_NAME}"}# function: if FILE exists then DO_SOMETHING.
# function: if $1($1==FILE) exists; then $2(do-$2)
function test_file_do()
{if [[ -e $1 ]]then$2fi
}FILE_NAME="books.txt"
touch ${FILE_NAME}# if ${FILE_NAME} exists; then do_msg
test_file_do ${FILE_NAME} do_msg[wit@test:tmp]$
三、参考内容
1、 无
.
本文由 lnlidawei 原创、整理、转载,本文来自于【博客园】; 整理和转载的文章版权归属【原创作者】; 转载或引用时【请保留文章的来源信息】:https://www.cnblogs.com/lnlidawei/p/19628277
