教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 范文大全 > 文秘资料 >

Linux下的shell编程入门

来源:网络收集 时间:2026-08-20
导读: 初步接触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 ech

初步接触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字,全部文档内容请下载后查看。喜欢就下载吧 ……
Linux下的shell编程入门.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/fanwen/2175687.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)