Re: In need of a SHELL Script - Please!!!
From: Alexander Dünisch (phaedrus_at_gmx.net)
Date: 10/28/03
- Next message: Stephane CHAZELAS: "Re: getting next free guid in password file ?"
- Previous message: Stephane CHAZELAS: "Re: deleting file with special character in name"
- In reply to: rbristol: "In need of a SHELL Script - Please!!!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 28 Oct 2003 20:54:15 +0100
On Tue, 21 Oct 2003 15:55:45 -0400, rbristol
<member45122@dbforums.com> wrote:
>
>I'm not terribly familiar with shell scripting and would like to know if
>someone has a script that loops through the files in a directory and
>replaces the first 3 letters of the file name while leaving the last 20
>characters the same.
>
>
>
>For example change 'OLD_01012003_101000.xls' to
>'NEW_01012003_101000.xls' (note that the 'new' and 'old' are consistent
>values that do not vary...but the time stamp does).
>
>
>
>Please let me know.
>
>
>
>(frustrated)...
>
>RBB
# sh,bash,ksh
cd directory_where_your_files_are
typeset -a old=(`ls OLD*`)
typeset -a new=()
for index in `seq -s " " 0 \`expr ${#old[@]} - 1\`` do
new[index]=`echo ${old[index]} | sed 's/OLD/NEW/'`
mv ${old[index]} ${new[index]}
done
- Next message: Stephane CHAZELAS: "Re: getting next free guid in password file ?"
- Previous message: Stephane CHAZELAS: "Re: deleting file with special character in name"
- In reply to: rbristol: "In need of a SHELL Script - Please!!!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|