首页 Linux下的shell编程入门

Linux下的shell编程入门

举报
开通vip

Linux下的shell编程入门 Linux shell shell shell Shell C Shell Linux Linux shell 1 date, bin #Program date #usageto ::show the date in this way ( ) echo Mr.$USER,Today is: echo date +%B%d%A echo Whish you a lucky day !...

Linux下的shell编程入门
Linux shell shell shell Shell C Shell Linux Linux shell 1 date, bin #Program date #usageto ::show the date in this way ( ) echo Mr.$USER,Today is: echo date +%B%d%A echo Whish you a lucky day ! 2 chmod +x date ls shell . [beichen@localhost bin]$ date Mr.beichen,Today is: January 13 Friday Whish you a lucky day ! bin [beichen@localhost bin]$ PATH=$PATH:$HOME/bin ( $HOME /home/beichen, bin ) date shell : [beichen@localhost /]$ bash date Mr.beichen,Today is: January 13 Friday Whish you a lucky day ! chmod +x date date Linux [beichen@localhost /]$ .date Mr.beichen,Today is: January 13 Friday Whish you a lucky day ! date . shell shell ls shell Shell 1 $N N 1 $1. C Linux 0 0 1 $0 $1 2 $0 $1 $0 $# ---- $? ---- shell shell 0 0 $* ---- P1: echo Program name is $0 echo There are totally $# parameters passed to this program echo 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 echo Please specify a file! else gzip $1 // mv $1.gz $HOME/dustbin // echo File $1 is deleted ! fi test shell ?D?D (test) shell if ( ) test shell shell 1 NULL( bash ) = != -n -z 2 test >? -eq -ge -le -ne -gt -lt 3 ! -a (and) -o (or) 4 test -d -f -L -r -s -w -x file1 ?Cnt(-ot) file2 1 2 ( ) shell for while until for for in do done for .gz #delete all file with extension of gz in the dustbin for I in $HOME/dustbin/*.gz do rm ?Cf $i echo $i has been deleted! done [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 done while do done until until do done do done : #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 The result is 5050! Shell if case If if 1 then elif 2 then elif 3 then .. else fi Linux if if fi elif else if elif Case case in 1| 2) :: 3| 4) :: 5| 6) :: *} :: esac case | case :: case $USER in beichen) Echo You are beichen! ;; liangnian) echo You are liangnian ; // echo Welcome! ;; // root) echo You are root!:echo Welcome! ;; // *) echo Who are you?$USER? ;; esac [liangnian@localhost bin]$ test You are liangnian Welcome! shell shell
本文档为【Linux下的shell编程入门】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_526487
暂无简介~
格式:pdf
大小:528KB
软件:PDF阅读器
页数:10
分类:互联网
上传时间:2013-04-26
浏览量:6