Linux下的shell编程入门
初步接触shell编程,很好的入门资料,感谢大家给力支持,现在免费供大家学习,哈哈
Linuxshell
shellshell
Shell
Shell
C
Linux
Linux
shell
1
#Program date
date,
bin
#usageto ::show the date in this way (echo
Mr.$USER,Today is:
+%B%d%A
)
echo date echo 2
Whish you a lucky day !
chmod +x date
ls
[beichen@localhost bin]$ date Mr.beichen,Today is: January 13 Friday
shell
Whish you a lucky day !
bin
初步接触shell编程,很好的入门资料,感谢大家给力支持,现在免费供大家学习,哈哈
[beichen@localhost bin]$ PATH=$PATH:$HOME/bin (
$HOMEdate
[beichen@localhost /]$ bash date Mr.beichen,Today is: January 13 Friday
/home/beichen,
bin
)
shell
:
Whish you a lucky day !
chmod +x date
Linux
[beichen@localhost /]$ .date Mr.beichen,Today is: January 13 Friday
date
Whish you a lucky day !
date
.shell
shell
ls
shell
Shell
1
$N
10
$12
$0
$0
$1.
C0
Linux1
N
$0
初步接触shell编程,很好的入门资料,感谢大家给力支持,现在免费供大家学习,哈哈
$# ----$? ----shell
shell
0$* ----P1:
echo Program name is $0
echo There are totally $# parameters passed to this programecho The last is $?echo
The parameters are $*
[beichen@localhost bin]$ P1 this is a test program //5
Program name is /home/beichen/bin/P1 //
There are totally 5 parameters passed to this program //The last is 0 //
The parameters are this is a test program //
del
#name: del
#author: liangnian
#this program to compress a file to the dustbin
if test $# -eq 0
then
初步接触shell编程,很好的入门资料,感谢大家给力支持,现在免费供大家学习,哈哈
echo else
Please specify a file!
gzip $1 //
mv $1.gz $HOME/dustbin //echo fi
File $1 is deleted !
test
(test)
shell
if
(shell
)
test
shellshell
1
NULL(
)
bash
= !=
-n -z 2
test
>?
初步接触shell编程,很好的入门资料,感谢大家给力支持,现在免费供大家学习,哈哈
-eq -ge -le -ne -gt -lt 3-a -o 4
(and)!
test
-d -f -L -r -s -w -x
file1 ?Cnt(-ot) file2
1
2
()
初步接触shell编程,很好的入门资料,感谢大家给力支持,现在免费供大家学习,哈哈
shellfor
for
do
in
forwhileuntil
done
for
.gz
#delete all file with extension of for I in $HOME/dustbin/*.gz do
gz
in the dustbin
rm ?Cf $i echo done
$i has been deleted!
[beichen@localhost bin]$.f_rmgz
/home/beichen/dustbin/nessus-4.0.0.2.tar.gz has been deleted! /home/beichen/dustbin/gftp-2.2.1.tar.gz has been deleted!
While
while
do
初步接触shell编程,很好的入门资料,感谢大家给力支持,现在免费供大家学习,哈哈
done
while
dodone
until
until
do
done
dodone
:
#test until
#add from 1 to 100
total=0
num=0
until test num ?Ceq 100
do
total=`expr $total + $num` //,
num=`expr $num+1`
done
echo
The result is $total
[beichen@localhost bin]$until
初步接触shell编程,很好的入门资料,感谢大家给力支持,现在免费供大家学习,哈哈
The result is 5050!
Shellifcase
If
if
1 then
elif 2 then
elif 3 then
..
else
fi
Linux
ififfielifelse if
elif
Case
case in
1|2)
::
3|4)
::
初步接触shell编程,很好的入门资料,感谢大家给力支持,现在免费供大家学习,哈哈
5|:: *}
6)
:: esac case
|case::
case $USER in beichen) Echo
You are beichen!;;
liangnian) echo echo root) echo
You are liangnian; //Welcome!
;; //
You are root!:echo Welcome!;; //
*)
echo esac
Who are you?$USER?;;
[liangnian@localhost bin]$ test
初步接触shell编程,很好的入门资料,感谢大家给力支持,现在免费供大家学习,哈哈
You are liangnian Welcome!
shell
shell
…… 此处隐藏:942字,全部文档内容请下载后查看。喜欢就下载吧 ……相关推荐:
- [文秘资料]班长职务辞职报告
- [文秘资料]完美的辞职报告
- [文秘资料]经典的员工辞职报告
- [文秘资料]医院口腔医生辞职报告
- [文秘资料]总经理辞职报告范文四篇
- [文秘资料]超市职员个人辞职报告
- [文秘资料]村妇联主任的辞职报告
- [文秘资料]辞职报告书格式
- [文秘资料]酒店辞职报告简单范文
- [文秘资料]联通的辞职报告
- [文秘资料]2017最新私企员工辞职报告范文
- [文秘资料]2019年度医院基层党组织书记抓党建述职
- [文秘资料]工作时间长辞职报告
- [文秘资料]辞职报告怎么写出来
- [文秘资料]个人能力原因辞职报告
- [文秘资料]网络工程师辞职报告
- [文秘资料]项目部辞职报告
- [文秘资料]缝纫工辞职报告怎么写
- [文秘资料]XXX州委书记述职报告
- [文秘资料]抓基层党建工作述职报告
- (王虎应老师讲课记录)六爻理象思维
- 八个常见投影机故障排除法
- 质量专业综合知识(中级)第一章质量管理
- 煤矿班组建设实施意见
- 我国快餐业与肯德基经营模式的比较与分
- 汽车保险杠模具标准化模架技术工艺研究
- 汽车二级维护作业团体赛比赛规程
- 装卸搬运工安全操作规程
- 高效的工作方法-刘铁
- 依据《生产安全事故报告和调查处理条例
- 2015专业PS夜景亮化效果图制作教程
- 企业劳动定额定员浅析
- 中枢神经系统医学影像学本科五年制第五
- 长城汽车参观探营第三站:研发试验中心
- 小升初语文专项训练
- 建筑工程质量检测资质分类与等级标准
- 周燕珉-我国养老社区的发展现状与规划
- 《生命里最后的读书会》读后感
- 实验室管理评审报告
- CCNA思科网院教程精华之网络基础知识




