list-glob.sh

来自「Shall高级编程」· Shell 代码 · 共 31 行

SH
31
字号
#!/bin/bash# list-glob.sh: Generating [list] in a for-loop, using "globbing"echofor file in *#           ^  Bash performs filename expansion#+             on expressions that globbing recognizes.do  ls -l "$file"  # Lists all files in $PWD (current directory).  #  Recall that the wild card character "*" matches every filename,  #+ however, in "globbing," it doesn't match dot-files.  #  If the pattern matches no file, it is expanded to itself.  #  To prevent this, set the nullglob option  #+   (shopt -s nullglob).  #  Thanks, S.C.doneecho; echofor file in [jx]*do  rm -f $file    # Removes only files beginning with "j" or "x" in $PWD.  echo "Removed file \"$file\"".doneechoexit 0

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?