随笔分类 - Shell
摘要:eval 相当于一个参数替换器,它会把所有 $开头的变量 进行求值替换,然后把替换后的结果当作一条命令来执行举个例子:#!/bin/bashPARA="hello world my friend"function Process(){ temp=$(eval echo \$$1 | cut -d ' ' -f 2-) #1 eval $1=\$temp #2}Process PARAecho $PARA说明:#1处eval先将它后面所有变量求值,$1==PARA,然后再执行 echo $PARA | cut -d ' ' -f 2-,得到处理
阅读全文
摘要:#!/bin/bashtab="\t"pipe="|"dash="--------"fmt="$pipe${dash}"lsallfile () {for i in ${1}/*do if [ -f "$i" ] then echo -e "$fmt${i##*/}" elif [ -d "$i" ] then echo -e "$fmt${i##*/}/" fmt="$pipe$tab$fmt"...
阅读全文
摘要:#!/bin/bashinc=""tab="\t"lsallfile () {for i in ${1}/*do echo -e "$inc${i##*/}" if [ -d "$i" ] then inc="$inc$tab" echo "" lsallfile "${i}" echo "" inc=${inc#"$tab"} fidone}if [ -z $1 ]then lsallfile ...
阅读全文
摘要:Table 5-3. Arithmetic test operators Test Comparison -lt Less than -le Less than or equal -eq Equal -ge Greater than or equal -gt Greater than -ne Not equal Table 5-2. File attribute operators Operato...
阅读全文
摘要:1. 为什么使用shell编程 使用shell进行程序设计的原因之一是,你可以快速、简单地完成编程。而且,即使是最基本的Linux安装也会提供一个shell。 虽然shell表面上和Windows的命令提示符相似,但是它具备更强大的功能以完成相当复杂的程序。你不仅可以通过它执行命令、调用Linux工具,还可以自己编写程序。shell执行shell程序,这些程序通常被称为脚本,它们是在运行时解释执行...
阅读全文
浙公网安备 33010602011771号