I'm trying to approach a problem but all I'm coming up with are complex ways to manipulate the data. But still not getting the desired outcome.
directory of files....
file-100-foo
file-100-man
file-100-chu
Need to copy the files and increment the number in the file name
file-101-foo
file-101-man
file-101-chu
Should be easy right?
dnbert
2
something like this (this is all pseudo so yeah don't take it exactly to be literal)
mv $filename `echo "$filename"|sed 's/100/101/g'`
I believe something like that should work for you. If you need it to increment do something like:
for k in `seq 102 200`; do cp $filename `echo "$filename"|sed 's/100/'$k'/g'`; done
mv $filename `echo "$filename"|sed 's/100/101/g'`
Where does $filename come from?
I tried - ls /dir | grep file > file-list1
that gets me a list of the files, but I'm not sure how to load each one into a cp statement and also sed replace 100 with 101.
dnbert
5
Filename is an environmental variable, you can assign it doing something like
filename="ls ${HOME}/dir"
echo `$filename`