一本完整的描述Unix Shell 编程的工具书的所有范例

源代码在线查看: ref-params.sh

软件大小: 1148 K
上传用户: buptbaishikele
关键词: Shell Unix 编程 范例
下载地址: 免注册下载 普通下载 VIP

相关代码

				#!/bin/bash				# ref-params.sh: Dereferencing a parameter passed to a function.				#                (Complex Example)								ITERATIONS=3  # How many times to get input.				icount=1								my_read () {				  #  Called with my_read varname,				  #+ outputs the previous value between brackets as the default value,				  #+ then asks for a new value.								  local local_var								  echo -n "Enter a value "				  eval 'echo -n "[$'$1'] "'  #  Previous value.				# eval echo -n "[\$$1] "     #  Easier to understand,				                             #+ but loses trailing space in user prompt.				  read local_var				  [ -n "$local_var" ] && eval $1=\$local_var								  # "And-list": if "local_var" then set "$1" to its value.				}								echo								while [ "$icount" -le "$ITERATIONS" ]				do				  my_read var				  echo "Entry #$icount = $var"				  let "icount += 1"				  echo				done  												# Thanks to Stephane Chazelas for providing this instructive example.								exit 0							

相关资源