(Linux newbie here)
I have a directory containing a master file ‘cs010101.SETUP’ and a number of sub-directories. Each sub-directory contains a large number of files including some of the format cs??????.dat3. I’m looking for a way to find all the cs??????.dat3 files and then for each, in its corresponding directory, create a soft link back to the master file (cs010101.SETUP) with the six digit number changed to the match the respective cs??????.dat3 file.
e.g If a sub-directory contains the file cs219254.dat3, I want to perform the command
ln -s ../cs010101.SETUP cs219254.SETUP
So far I’ve got as far as the find command
find . -name "cs*dat3"
and looked at piping to cut in order to extract the number
find . -name "cs*dat3" | cut -c 13-18
(this works currently as the naming convention for the sub-directories is consistent, though would be nice if didn’t have to rely on that fact).
But now I’m stumped!
Use sed. Script may look like this: