摘要: 1 $$:显示PID编号[tandesir@localhost shell]$ echo $80682 $?:退出状态[tandesir@localhost shell]$ echo $?0[tandesir@localhost shell]$ ls test.txtls: 无法访问 test.txt: 没有那个文件或目录[tandesir@localhost shell]$ echo $?2[tandesir@localhost ~]$ true[tandesir@localhost ~]$ echo $?0[tandesir@localhost ~]$ false[tandesir@loc 阅读全文
posted @ 2011-10-07 21:08 j2ee技术 阅读(193) 评论(0) 推荐(0) 编辑
摘要: 运用select和case可以制作简单的交互式菜单。#! /bin/bashselect CHIOCE in show help exitdo case "$CHIOCE" in show) ls ;; help) echo "Help : This is a joke for test!" ;; exit) exit 0 ;; esacdone 阅读全文
posted @ 2011-10-07 20:35 j2ee技术 阅读(187) 评论(0) 推荐(0) 编辑
摘要: 【方法1】运用for in语句(1) bash#! /bin/bash sum=0; for i in {1..100} do ((sum = sum + i)) done echo $sum (2) perl#! /usr/bin/perl $sum=0; for ($i = 0; $i <=100 ; $i+=1) { $sum +=$i; } print "$sum\n"; 【方法2】运用while语句(1) bash#! /bin/bash i=0; sum=0; while [ "$i" -lt 100 ] do ((i = i + .. 阅读全文
posted @ 2011-10-07 20:19 j2ee技术 阅读(341) 评论(0) 推荐(0) 编辑