linux.docx
- 文档编号:11951381
- 上传时间:2023-04-16
- 格式:DOCX
- 页数:10
- 大小:15.83KB
linux.docx
《linux.docx》由会员分享,可在线阅读,更多相关《linux.docx(10页珍藏版)》请在冰豆网上搜索。
linux
[root@localhost~]#nodehost=beijing.WEB#9.22
[root@localhost~]#user="zhangming"
[root@localhost~]#path=/bin:
/usr/bin:
/etc/bin
[root@localhost~]#count=10
[root@localhost~]#echo$nodehost$user$path$count
beijing.WEBzhangming/bin:
/usr/bin:
/etc/bin10
[root@localhost~]#
[root@localhostgames]#readuserauserbuserc#9.23
HuaChunliNiuYueZhaoHanghang
[root@localhostgames]#echo$usera$userb$userc
HuaChunliNiuYueZhaoHanghang
[root@localhostgames]#
[root@localhost~]#dir=/usr#9.24
[root@localhost~]#echo$dir
/usr
[root@localhost~]#cd$dir/games
[root@localhostgames]#pwd
/usr/games
[root@localhostgames]#echo$dir
$dir
[root@localhostgames]#
[root@localhostgames]#echo$dir_1#9.25
[root@localhostgames]#echo${dir}_1#gen9.24youguanlian.
/usr_1
[root@localhostgames]#str="Thisisastring"
[root@localhostgames]#echo"${str}enttestofvariables"
Thisisastringenttestofvariables
[root@localhostgames]#echo"$strenttestofvariables"
testofvariables
[root@localhostgames]#
[root@localhostgames]#readonlydir#9.26
[root@localhostgames]#dir=/home/usr01
bash:
dir:
readonlyvariable
[root@localhostgames]#
#9.27:
lue.
[root@localhost~]#dir=/root/Example#9.28,createfolderExample
[root@localhost~]#echo$dir
/root/Example
[root@localhost~]#bash
[root@localhost~]#echo$dir
[root@localhost~]#
[root@localhost~]#name=Zhang;exportname#9.29
[root@localhost~]#title=Dr.;exporttitle
[root@localhost~]#greeting="goodmorning"
[root@localhost~]#cat>var_test
name=Wang
echo"$greeting$title$name!
"
[root@localhost~]#bashvar_test
Dr.Wang!
[root@localhost~]#echo"$greeting$title$name!
"
goodmorningDr.Zhang!
[root@localhost~]#
[root@localhost~]#echo"Hello$LOGNAME!
"#9.31
Helloroot!
[root@localhost~]#echo$PATH
/usr/kerberos/sbin:
/usr/kerberos/bin:
/usr/lib/ccache:
/usr/local/sbin:
/usr/sbin:
/sbin:
/usr/local/bin:
/usr/bin:
/bin:
/root/bin
[root@localhost~]#myprog#jianlikongdekezhixingwenjian"myprog".
bash:
myprog:
commandnotfound
[root@localhost~]#./myprog
[root@localhost~]#PATH=$PATH:
.
[root@localhost~]#echo$PATH
/usr/kerberos/sbin:
/usr/kerberos/bin:
/usr/lib/ccache:
/usr/local/sbin:
/usr/sbin:
/sbin:
/usr/local/bin:
/usr/bin:
/bin:
/root/bin:
.
[root@localhost~]#./myprog
[root@localhost~]#echoPS1is"$PS1",PS2is"$PS2"
PS1is[\u@\h\W]\$,PS2is>
[root@localhost~]#cat<
>JoneDoe
>DavidNice
>MasoodShah
>End
[root@localhost~]#PS1="[$USER@$HOSTNAME]$"
[root@localhost.localdomain]$PS2=!
[root@localhost.localdomain]$cat<
!
JoneDoe
!
DavidNice
!
MasoodShah
!
End
[root@localhost.localdomain]$
[root@localhost~]#mkdir-pproject/srcscripts#9.32
[root@localhost~]#WORKDIR=$HOME/project/src;exportWORKDIR
[root@localhost~]#cd~/scripts
[root@localhostscripts]#cat>env_test
echo"Iam$LOGNAME@$HOSTNAME."
cd$WORKDIR
echo"Iamnowin$PWD."
[root@localhostscripts]#.env_test
Iamroot@localhost.localdomain.
Iamnowin/root/project/src.
[root@localhostsrc]#echo$PWD
/root/project/src
[root@localhostsrc]#
[root@localhost~]#cat>var_test#9.33
echoMynameis$0,Ihave$#parameters,theyare$@.
echoThefirstofthemis\"$1\".
[root@localhost~]#chmoda+xvar_test
[root@localhost~]#./var_testHowareyou
Mynameis./var_test,Ihave3parameters,theyareHowareyou.
Thefirstofthemis"How".
[root@localhost~]#./var_test"Howareyou"cherry
Mynameis./var_test,Ihave2parameters,theyareHowareyoucherry.
Thefirstofthemis"Howareyou".
[root@localhost~]#
[root@localhost~]#date#9.34
2011年09月17日星期六10:
11:
05CST
[root@localhost~]#set`date`
[root@localhost~]#echo$6$2$3$1
CST09月17日2011年
[root@localhost~]#
[root@localhost~]#cat>proc1#9.35
echo$0,$#,$1,$2,$3,$4,$5.
shift
echo$0,$#,$1,$2,$3,$4,$5.
shift2
echo$0,$#,$1,$2,$3,$4,$5.
[root@localhost~]#bashproc1ABCDE
proc1,5,A,B,C,D,E.
proc1,4,B,C,D,E,.
proc1,2,D,E,,,.
[root@localhost~]#
[root@localhost~]#rmfile1#9.36
rm:
是否删除普通空文件“file1”?
y
[root@localhost~]#echo$?
0
[root@localhost~]#rmfile2
rm:
无法删除“file2”:
没有那个文件或目录
[root@localhost~]#echo$?
1
[root@localhost~]#
[root@localhost~]#echo$0,$$#9.37
bash,2495
[root@localhost~]#sleep30&
[1]2532
[root@localhost~]#echo$!
!
2532
[root@localhost~]#cat>pid_test
echo"Mynameis$0,myPIDis$$."
[1]+Donesleep30
[root@localhost~]#chmoda+xpid_test
[root@localhost~]#./pid_test
Mynameis./pid_test,myPIDis2539.
[root@localhost~]#.pid_test
Mynameisbash,myPIDis2495.
[root@localhost~]#
[root@localhost~]#a=13#9.38
[root@localhost~]#expr"$a"-4+2
11
[root@localhost~]#expr4\*5
20
[root@localhost~]#expr5+7/3
7
[root@localhost~]#expr`expr5+7`/3
4
[root@localhost~]#expr$a\>=3;echo$?
1
0
[root@localhost~]#expr5\&"$a";echo$?
5
0
[root@localhost~]#expr5\&0;echo$?
0
1
[root@localhost~]#expr5\|0;echo$?
5
0
[root@localhost~]#a=`expr$a-2`
[root@localhost~]#echo$a
11
[root@localhost~]#
[root@localhost~]#user=smith#9.39
[root@localhost~]#test"$user"=smith
[root@localhost~]#echo$?
0
[root@localhost~]#test-z"$user"
[root@localhost~]#echo$?
1
[root@localhost~]#
[root@localhost~]#user1="TomSmith"#9.40
[root@localhost~]#test"$user1"="TomSmith"
[root@localhost~]#echo$?
0
[root@localhost~]#test$user1="TomSmith"
bash:
test:
toomanyarguments
[root@localhost~]#echo$?
2
[root@localhost~]#test"$user2"=Smith
[root@localhost~]#echo$?
1
[root@localhost~]#test$user2=Smith
bash:
test:
=:
unaryoperatorexpected
[root@localhost~]#echo$?
2
[root@localhost~]#
[root@localhost~]#x1=5#9.41
[root@localhost~]#test"$x1"-eq5;echo$?
0
[root@localhost~]#
[root@localhost~]#test-f/root/proc1;echo$?
#9.42
0
[root@localhost~]#gccproc12>err
[root@localhost~]#test-serr&&echo"Errorsfound"
Errorsfound
[root@localhost~]#
[root@localhost~]#mkdirproc#9.43
[root@localhost~]#cat>dir_test
test-d$1&&echo"$1isadirectory"&&exit0
echo"$1isnotadirectory";exit1
[root@localhost~]#chmoda+xdir_test
[root@localhost~]#./dir_testproc
procisadirectory
[root@localhost~]#
[root@localhost~]#cat>file#9.44
hello
[root@localhost~]#test-ffile-a!
-sfile
[root@localhost~]#echo$?
1
[root@localhost~]#readabc
275
[root@localhost~]#test\($a-eq0-o$b-gt5\)-a$c-le8
bash:
test:
(2:
integerexpressionexpected
[root@localhost~]#echoabc
abc
[root@localhost~]#echo$a$b$c
275
[root@localhost~]#test\($a-eq0-o$b-gt5\)-a$c-le8
[root@localhost~]#echo$?
0
[root@localhost~]#cat>check_input
echo-n"Inputanumber(1-10):
"
reada
test$a-lt1-o$a-gt10&&echoerror!
&&exit1
echook
exit0
[root@localhost~]#bashcheck_input
Inputanumber(1-10):
5
ok
[root@localhost~]#bashcheck_input
Inputanumber(1-10):
15
error!
[root@localhost~]#
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- linux
![提示](https://static.bdocx.com/images/bang_tan.gif)