On Saturday 16 August 2008 18:06:40 David Bolt wrote:
On Sat, 16 Aug 2008, David C. Rankin wrote:-
While you've already had some answers, here's a few other tips.
The problem is that I cannot get sed to allow substitution of a value contained in the sed expression. So far, I can do:
for i in $(ls); do
ORIG_FNAME=$i NEW_FNAME=$(echo $i | sed -e 's/^100/`date +%Y%m%d`/')
^ ^ These aren't the same as using double-quotes. Bash won't do expansion or execution within single quoted strings.
Also, there's no need for the "echo | sed" combination. You could use:
DATE=$(date +%Y%m%s) for ORIG_FNAME in * do if [ "${ORIG_FNAME::3}" == "100" ] # check first three characters of $ORIG_FNAME then NEW_FNAME=${DATE}${ORIG_FNAME:3} else continue # skip this file fi
Why not for ORIG_FNAME in 100* do :) Anders -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org