Simple overwriting of files in current working directory

When I do server configurations for large numbers of domain names, I like keeping files organized specifically by their domain name, and then I have a sample file that I build off of.

Often times I want to create new configuration files from an existing directory of all of those domain names (for example, if I needed zone records for each one)

for x in `ls`; do cat /directory1/filename >> /directory2/new/$x; done

what it does is for every line in ls (of the current directory) it outputs a file into /directory2/new/(every line in LS)

It’s a great timesaver… and can be used in a bunch of different ways

for x in `ls`; do touch $x; done
update every file in the directory to current time, great for organizing your config directories when you have a known working config

for x in `cat list`; do rm -rf $x; done
cat a file and delete each file in list

the list goes on…

Leave a Comment