|
|
|
| Top White Papers
Current Newswire:
Linux Gazette: Variable Mangling in Bash with String OperatorsSep 23, 2000, 17:41 (1 Talkback[s])(Other stories by Pat Eyler) "Have you ever wanted to change the names of many files at once? How about using a default value for a variable if it has no value? These and many other options are available to you through string operators in bash and other Bourne shell derived shells." "There are three kinds of variable substitution:
"There are two kinds of pattern matching available, matching from the left and matching from the right. The operators, with their functions and an expample, are shown in the following table... These operators can be used to do a variety of things. For example, the following script will change the extension of all '.html' files to '.htm'. '.html' files to '.htm'.
#!/bin/bash
# quickly convert html filenames for use on a dossy system
# only handles file extensions, not file names
for i in *.html; do
if [ -f ${i%l} ]; then
echo ${i%l} already exists
else
mv $i ${i%l}
fi
done
Related Stories:
0 Talkback[s]
(click to add your comment)
|