Tag Archives: bash

super crappy script to make a ton of directories and files

needed to create a really quick script to just generate a ton of directories and files to fill them mainly to create something to test backups with.  it’s not quite elegant, but to be honest it’s pretty quick and got the job done, anyway…


# a script to create content, creates 1500 directories, a 1MB file and a %K file and copies it into all subdirs
#creates the dummy content files
dd if=/dev/zero of=dummy bs=1024 count=1024
dd if=/dev/zero of=dummysmall bs=1024 count=5
#creates 1500 directories in current directory
mkdir foo{1..1500}
#copies the dummy files
find . -type d -exec cp dummy {}/ \;
find . -type d -exec cp dummysmall {}/ \;
#clean up
rm -r dummmy dummysmall
echo "done!"
Tagged , ,

change that, son.


This was a great help.  Basically I had to take about 8 files with the word “stage” in them and replace it with “dev”

for i in ./*stage*;do mv -- "$i" "${i//stage/dev}";done

Bang, done!

Tagged , ,

sed, grep and updating a static website.

so one of the offices at the company recently moved from one city to another. they are in the process of migrating the public website from an old static page to a new page using wordpress. if the new site was online, changing a footer with the office address wouldn’t be a problem.  well the new shiny office doesn’t come with the new shiny website.  had to do some cli kung-fu to get the address changed.

so i figured since line of the address in html was on a separate line the best thing was to grep for the string, then use sed to replace it, it’s not elegant but it worked.

first thing we do, we back up our crap in case i totally screw it up. then once my backups are done i run the first part of the string:

grep -lr -e ‘123 Old Street Location, Floor 3’ * | xargs sed -i ‘s/123 Old Street Location, Floor 3/555 New Street Location Suite 4/g’

then let’s do the new city and zip

grep -lr -e ‘Cambridge, MA 02139 USA’ * | xargs sed -i ‘s/Cambridge, MA 02139 USA/Boston, MA 02111 USA/g’ 

this got the job done and quickly since the problem was sitting around for a little while and no one seemed to notice.

Tagged , , ,