Shell Notepad

xiaoxiao2021-03-06  20

1 Single quotes and double quotes are strict. It prevents any variable extensions. Dual quotes can prevent wildcards from expand but allow variables to expand. 2 Use Case to SELECT OS TYPE # Moved Shell Code from '.MachType' INTO Here So That One Less Process # is executed. Platform = "unknown" if [-f / usr / 5bin / uname]; then os_type = `/ usr / 5bin / uname -r` platform = `/ usr / 5bin / uname -m` Else IF [-f / usr / bin / uname]; Then OS_TYPE =` / usr / bin / uname -r` platform = `/ usr / bin / uname -m` Else IF [-f / bin / uname]; the os_type = `/ bin / uname -r` platform =` / bin / uname -m` Fi Fi

# Note That Sunos 5.0 Can Run Sunos 4.x Binaries, But Not Vice-Versa. # Note That Sysv88 R4x Can Run Sysv88 R32 Binaries, But Not Vice-Versa.

Case $ Platform in

############################################################ -4 Running ... ############################################################## # SUN4 *) Case $ OS_TYPE IN 4 *) Platform = Sun4 ;; # ... Sunos 4.x. We can't Run Elf Binaries.

5 *) Platform = SUN44 ;; # ... Sunos 5.x. We Run Both Sunos 4.x # binaries and sunos 5.x Elf Binaries. ESAC ;;

############################################################ SUN-3. ############################################# | sun3 *) Platform = SUN3 ;;

################################################## Solaris on x86 #################################################### Platform = pc ;; ############################################################### # We're a 68k moto vme. ############################################################################################################################################################################################################################################################################################ #### m68030) Platform = m68k ;;

################################################################# 88K MCG VME Running R32. # We can not run r4x Elf binaries. #################################################################################################################################################################################################################################### ########## m8100) Platform = m88k ;; ######################################################################################################################################################################################################################################### ############ # We're an 88k mcg vme Running R4x. # We Run Both R32 Coff Binaries As Well AS R4x Elf Binaries. ########################################################################################################################################################################################################################################## ######################### m88k) platage = m88k4 ;;

################################################################# HP 9000 WorkStation. ############################################################### / 7 *) Platform = HP97 ;;

9000 / *) Platform = HP9 ;;

Esac # end of .machtype code

3 Joint logic operation IF ["x $ platform"! = "X" -a! -H / tmp / gsmtt / bin]; Then! Unary NEGATION Operator. -A binary and operator.4 redirect (shield) input output RM -RF / TMP / TT> / DEV / NULL 2> & 15 Exec calls EXEC's back command will not be executed (process overwrite) 6 About assignment space - do not space! For: a = '$ 0' wrong: a = '$ 0'A =' $ 0'A = '$ 0'Reference: shell Programming (1) Shell Programming (2) Shell Programming (3) Shell Programming Learning Notes (1) Shell Programming Learning Notes (2) Bourne Shell and Shell Programming (1)

转载请注明原文地址:https://www.9cbs.com/read-61094.html

New Post(0)