multiple file copies

Associate
Joined
28 May 2003
Posts
1,852
hi there,

so lets say i have two source files and lets call them config1 and config2. in addition lets say i have two additional files that are lists of mac addresses [one per line], lets call them mac1 and mac2. lets assume mac1 contains 25 mac addresses, and mac2 contains 50 mac addresses. is there a way that end up with 25 copies of config1 each named as the mac addresses in the list of mac1, and 50 copies of config2 each named as the mac addresses in the list of mac2?

thanks in advance, andy.
 
managed to write a shell script to do this, i'm not sure if it's the most elegant way of doing it, but it works!

for sma in $( cat mac ); do
cp config $sma
done

my interpretation of that is create a variable for each line of a file called mac, and then pass that variable to the target_file portion of the cp command to replicate a file called config.

from a bit of reading that might be a 'useless use of cat', since i get the impression cat is primarily used with multiple files...but i'm a newbie, and this does what i need - i now have the 400 files i was after in a matter of seconds! if anyone cares to point out a more elegant way of doing things such as this, please feel free!
icon_smile.gif
 
just noticed that in finder the files appear normally, and open fine...but if i list them out at the command line they all have a trailing ? on the file name... and if i copy the files to a usb stick and then read them from a windows machine they all appear to have a weird character on the end that i haven't seen before. this has to be something to do with the input lists of mac addresses as with dummy files with made up addresses the script works fine. i've checked the proper input lists and they are definitely just one mac address per line with no spurious characters or whitespace anywhere... any ideas?! thanks.
 
Back
Top Bottom