ex39.sh
来自「Shall高级编程」· Shell 代码 · 共 36 行
SH
36 行
#!/bin/bashROOT_UID=0 # Only users with $UID 0 have root privileges.E_NOTROOT=65E_NOPARAMS=66if [ "$UID" -ne "$ROOT_UID" ]then echo "Must be root to run this script." # "Run along kid, it's past your bedtime." exit $E_NOTROOTfi if [ -z "$1" ]then echo "Usage: `basename $0` find-string" exit $E_NOPARAMSfiecho "Updating 'locate' database..."echo "This may take a while."updatedb /usr & # Must be run as root.wait# Don't run the rest of the script until 'updatedb' finished.# You want the the database updated before looking up the file name.locate $1# Without the 'wait' command, in the worse case scenario,#+ the script would exit while 'updatedb' was still running,#+ leaving it as an orphan process.exit 0
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?