Linux Shell编程入门 (2)
来源:互联网 发布:python 输出布尔值 编辑:程序博客网 时间:2024/06/06 19:38
关于变量,还需要知道几个与其相关的Linux命令。 env用于显示用户环境区中的变量及其取值;set用于显示本地数据区和用户环境区中的变量及其取值;unset用于删除指定变量当前的取值,该值将被指定为NULL;export命令用于将本地数据区中的变量转移到用户环境区。 下面我们来看一个更复杂的例子,结合这个例子,我们来讲述Shell Script的语法。 1 #!/bin/bash 2 # we have less than 3 arguments. Print the help text: 3 if [ $# -lt 3 ] ; then 4 cat < 5 ren -- renames a number of files using sed regular expressions 6 7 USAGE: ren 'regexp' 'replacement' files... 8 EXAMPLE: rename all *.HTM files in *.html: 9 ren 'HTM$' 'html' *.HTM 10 11 HELP 12 exit 0 13 fi 14 OLD="$1" 15 NEW="$2" 16 # The shift command removes one argument from the list of 17 # command line arguments. 18 shift 19 shift 20 # $* contains now all the files: 21 for file in $*; do 22 if [ -f "$file" ] ; then 23 newfile=`echo "$file" | sed "s/${OLD}/${NEW}/g"` 24 if [ -f "$newfile" ]; then 25 echo "ERROR: $newfile exists already" 26 else 27 echo "renaming $file to $newfile ..." 28 mv "$file" "$newfile" 29 fi 30 fi 31 done
- [linux]linux Shell编程入门 (2)
- Linux Shell编程入门 (2)
- Linux Shell编程入门 (2
- Linux Shell编程入门
- linux Shell编程入门
- Linux Shell编程入门
- Linux Shell编程入门
- Linux Shell编程入门
- Linux Shell编程入门
- Linux Shell编程入门
- Linux Shell编程入门
- Linux Shell编程入门
- Linux Shell编程入门
- linux shell编程入门
- Linux shell编程入门
- Linux Shell编程入门
- Linux Shell编程入门
- Linux Shell编程入门
- 关于SQL优化的一些知识
- 好長時間沒有C#開發程序了
- BTree,B-Tree,B+Tree,B*Tree都是什么
- volist 换行显示
- IE,firefox内存溢出原因与解决方法
- Linux Shell编程入门 (2)
- 函数指针和函数数组
- History of C++
- 基于.NET2.0的System.Net.Mail发送邮件
- 弹出层效果
- (转)linux Crond 执行预定任务
- 分页存储过程及调用方法
- 业务建模时期(上)
- It will cause a new session when you use lazy loading collection, and the collection will assicated with the new session and the