if [ -z "$DISTDIR" ] then # set DISTDIR to /usr/src/distfiles if not already set DISTDIR=/usr/src/distfiles fi export DISTDIR if [ -d ${WORKDIR} ] then # remove old work directory if it exists rm -rf ${WORKDIR} fi mkdir ${WORKDIR} cd ${WORKDIR} tar xzf ${DISTDIR}/${...
Examine a new file. If the filename is missing, the "current" file (see the :n and :p commands below) from the list of files in the command line is re-examined. A percent sign (%) in the filename is replaced by the name of the current file. A pound sign (#) is replaced by...
test -f /etc/fstab ## true if a regular file test -h /etc/rc.local ## true if a symbolic link [ -x "$HOME/bin/hw" ] ## true if you can execute the file [[ -s $HOME/bin/hw ]] ## true if the file exists and is not empty 整数测试 整数之间的比较使用-eq、-ne、-gt...
for file in $*; do if [ -f "$file" ] ; then newfile=`echo "$file" | sed "s/${OLD}/${NEW}/g"` if [ -f "$newfile" ]; then echo "ERROR: $newfile exists already" else echo "renaming $file to $newfile ..." mv "$file" "$newfile" fi fi done 1. 2. 3. 4. 5....
-a file If file exists. -b file If file exists and is a block special file. -c file If file exists and is a character special file. -d file If file exists and is a directory. -e file If file exists. -f file If file exists and is a regular file. -g file If file exists an...
if [ -d work ] then # remove old work directory if it exists rm -rf work fi mkdir work cd work tar xzf /usr/src/distfiles/sed-3.02.tar.gz cd sed-3.02 ./configure --prefix=/usr make 虽然可以使用这个自动编译脚本,但它不是很灵活。基本上,bash 脚本只包含在命令行输入的所有命令列表。虽...
EN我在GitLab、Docker和AWS之间创建了CI (连续集成),配置如下:编程语言: 编译器,解释器 编程语言...
Test if File Exists Send Email Example Get Parse Current Date Wait Command Sleep Command Create and Execute First BASH Program: You can run bash script from the terminal or by executing any bash file. Run the following command from the terminal to execute a very simple bash statement. The ou...
博主使用 ubuntu 系统, shell 为 bash. 这个脚本也可以用在 mac 系统上.听说 windows 系统出了 ubuntu on windows, 不知道能不能使用这个脚本.
== 等于,如:if [ "a"=="b" ],与=等价 注意:==的功能在[[]]和[]中的行为是不同的,如下: [[ a == z* ]] # 如果a以"z"开头(模式匹配)那么将为true [[ a == "z*" ]] # 如果a等于z*(字符匹配),那么结果为true [ a == z* ] # File globbing 和word splitting将会发生 [ "a" ...