📄 ex43.sh
字号:
#!/bin/bash# Exercising "eval" ...y=`eval ls -l` # Similar to y=`ls -l`echo $y #+ but linefeeds removed because "echoed" variable is unquoted.echoecho "$y" # Linefeeds preserved when variable is quoted.echo; echoy=`eval df` # Similar to y=`df`echo $y #+ but linefeeds removed.# When LF's not preserved, it may make it easier to parse output,#+ using utilities such as "awk".echoecho "==========================================================="echo# Now, showing how to do something useful with "eval" . . .# (Thank you, E. Choroba!)version=3.4 # Can we split the version into major and minor #+ part in one command?echo "version = $version"eval major=${version/./;minor=} # Replaces '.' in version by ';minor=' # The substitution yields '3; minor=4' #+ so eval does minor=4, major=3echo Major: $major, minor: $minor # Major: 3, minor: 4
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -