I've been successfully running a script that prints out the names of the files in a specific directory by using
for f in data/*
do echo $f
and when I run the program it gives me:
data/data-1.txt
data/data-2.txt
data/data-3.txt
(the files in the data directory)
however, when I need to change all of the file names from data-*.txt to mydata-*txt, I can't figure it out.
I keep trying to use sed s/data/mydata/g $f
but it prints out the whole file instead and doesn't change the name correctly. Can anybody give me some tips on how to change the file names? it seems to also change the name of the directory if I use SED, so I'm kind of a dead end. Even using mv
doesn't seem to do anything.