Hi,
I am new to scripting, so any help on this would be much appreciated.
I am trying to rename a bunch of files, taking the names sequentially from a list read in another file...
# ls oldnames
file_1
file_2
file_3
# cat names
red
yellow
green
I want the files to take on the names red yellow green as they are read line by line from the file "names"
ie
cp oldnames/file_1 newnames/red
cp oldnames/file_2 newnames/yellow
cp oldnames/file_3 newnames/green
etc....
What I have tried (but doesn't work) -
#! /bin/bash
ls . |while read line
do
echo $line
cat names | while read xx
do
cp $line ../newnames/$xx
done
done
This creates new files but only copies the last entry from the ls to each of them
As you can see my scripting skills are not great - any ideas would be much appreciated.