30.11.07
Loops
Loops: "#!/bin/bash # list-glob.sh: Generating [list] in a for-loop, using 'globbing' echo for 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. done echo; echo for file in [jx]* do rm -f $file # Removes only files beginning with 'j' or 'x' in $PWD. echo 'Removed file \'$file\''. done echo exit 0"
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment