shell bash shell scripts shell if-then-else…shell script info bashbashshellhttp://www.oreilly.com.tw/chinese/linux/learn_bashshell.html 40.1. bash shell scripts keywords shell \n shell shell script 40.2. variable $ MYNAME=”smith ” Shell Scripts $ MYAGE=35$ echo $MYNAME $MYAGEs mith 35 shell $ NUMBER=”10″$ expr $NUMBER + 5+15 shell script shellscript $ FILENAME=”My Document”$ ls $FILENAMEls: My: No such file or directory lsls:
Document: No such file or directory$ ls -l “$FILENAME”My Documentls$ HAT=”fedora”$ echo “The plural of $HAT is $HATs”The plural of fedora is HATs$ echo “The plural of $HAT is ${HAT}s”The plural of fedora is fedoras 40.3. Scriptechoprintf17434. $ echo “Hello world”Hello world$ printf “I am %d years old\n” `expr 20 + 20`I am 40 years old Shell script readstdin $ read name Sandy Smith$ echo “I read the name $name”I read the name Sandy Smith 40.4. Boolean testtruefalseshell0Linuxshellreturn value exit status$? $ cat myfile My name is Sandy Smith andI really like Fedora Linux$ grep Smith myfileMy name is Sandy Smith and$ echo $?0$ grep aardvark myfile$ echo $?1 Linuxmanpage0LinuxPOSIX test[ bash shelltesttest01 Enter Shell Scripts $ test 10 -lt 510 < f2f1f2s1 =" s2s1">
Download 40. Shell Scripts.
0 comments:
Post a Comment