A little bash script help...

Soldato
Joined
18 Oct 2002
Posts
7,139
Location
Ironing
I've never taken the time to learn bash properly, and so I need a little help doing a very simple job:

I'm in a directory, and I've got a bunch of sub-directories, and a file. I want to copy that file into each of the subdirectories, but only those that start with a digit [0-9]. Basically this:

Code:
foreach directory in directorylist {

if directory =~ /[0-9](.*)/ {
copy file.txt directory/
}

}

How would I do this in bash?
 
Back
Top Bottom