LinuxShell脚本编程实例.doc_第1页
LinuxShell脚本编程实例.doc_第2页
LinuxShell脚本编程实例.doc_第3页
LinuxShell脚本编程实例.doc_第4页
LinuxShell脚本编程实例.doc_第5页
已阅读5页,还剩1页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

#! /bin/shecho Current command is $0echo The first parameter is $1echo The second parameter is $2echo The third parameter is $3echo Total of parameters if $#echo Current PID is $#!/bin/bashtimes=0until $times = 3 ;doecho I love linux.sleep 2times=expr $times + 1done#!/bin/bash# menu shell script. samli 2004.4.19until echo List Directory.1 echo Change Directory.2 echo Edit File.3 echo Remove File.4 echo Exit Menu.5 read choice test $choice = 5do case $choice in 1) ls; 2) echo enter target directory: read dir cd $dir ; 3) echo enter file name: read file vi $file ; 4) echo enter file name: read file rm $file ; 5) echo Goodbye ; *) echo illegal option, please input again. esacdone#! /bin/shvar1=abcdefgecho $var1var2=1234echo The value of var2 is $var2echo$HOMEecho$PATHecho$PWD#! /bin/shnum=0while $num -le 10 do num=expr $num + 1 if $num -eq 5 then continue fi square=expr $num * $num echo $squaredone#!/bin/bash# Gnu bash versions 2.x# The Party Program-Invitations to friends from the# guest fileguestfile=./guests#/shell/guestsif ! -e $guestfile then printf $guestfile#*/ non-existent exit 1fiexport PLACE=Sarotinis( Time=$(date +%H) + 1 )set cheese crackers shrimp drinks hot dogs sandwichesfor person in $(cat $guestfile)do if $person = root then continue else # Start of here document mail -v -s Party $person Hi $person! Please join me at $PLACE for a party! Meet me at $Time oclock. Ill bring the ice cream. Would you please bring $1 and anything else you would like to eat? Let me know if you cant make it. Hope to see you soon. Your pal, ellie$(hostname) FINIS shift if ( $# =0 ) then set cheese crackers shrimp drinks hot dogs sandwiches fi fidone printf Bye.#!/bin/sh# Standard AT&T Bourne Shell# The Party Program-Invitations to friends from the# guest fileguestfile=./guests # /home/ellie/shell/guestsif ! -f $guestfile then echo 慴asename $guestfile?non-existent exit 1fiPLACE=Sarotinisexport PLACETime=date +%HTime=expr $Time + 1set cheese crackers shrimp drinks hot dogs sandwichesfor person in $(cat $guestfile)do if $person = root then continue else # Start of here document mail -v -s Party $person Hi $person! Please join me at $PLACE for a party! Meet me at $Time oclock. Ill bring the ice cream. Would you please bring $1 and anything else you would like to eat? Let me know if you cant make it. Hope to see you soon. Your pal, elliehostname FINIS shift if $# -eq0 then set cheese crackers shrimp drinks hot dogs sandwiches fi fidone echo Bye.#!/bin/sh# Scriptname: args# Script to test command line argumentsecho The name of this script is $0.echo The arguments are $*.echo The first argument is $1.echo The second argument is $2.echo The number of arguments is $#.oldargs=$*set Jake Nicky Scott # reset the positional parametersecho All the positional parameters are $*.echo The number of postional parameters is $#.echo GoodVbye for now, $1 set $(date) #reset the positional parametersecho The date is $2 $3, $6.echo The value of $oldargs is $oldargs.set $oldargsecho $1 $2 $3# Name: bigfiles# Purpose: Use the find command to find any files in the root# partition that have not been modified within the past n (any# number within 30 days) days and are larger than 20 blocks# (512 byte blocks)if ( $# != 2 ) #or $# -ne 2 then echoUsage: $0 mdays size 1&2 exit 1fiif ( $1 0 | $1 30 ) #or $1 -lt 0 -o $1 -gt 30 then echo mdays is out of range exit 2fiif ( $2 # or $2 -le 20 then echo size is out of range exit 3fifind / -xdev -mtime $1 -size +$2#!/bin/bash# Scriptname: checker# Script to demonstrate the use of special variable# modifiers and argumentsname=$1:?requires an argument echo Hello $name#!/bin/bash# This is the first Bash shell program of the day.# Scriptname: greetings# Written by:Barbara Bashfulecho Hello $LOGNAME, its nice talking to you.echo Your present working directory is pwd.echo You are working on a machine called uname -n.echo Here is a list of your files.ls # list files in the present working directoryechoBye for now $LOGNAME. The time is date +%T!#!/bin/bash# Scriptname: greetings2echo This script is called $0.echo$0$1 and $2echo The number of positional parameters is $#!/bin/bash# Scriptname: idcheck# purpose:check user id to see if user is root.# Only root has a uid of

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论