Posts

Showing posts from May 31, 2009

find and perl as alternative for sed

In continuation of my migration, some directories with HTML contents their are manually inputted by strings that would let a typical user to edit manually all the HTML files for just a sake of changing a text. However, Perl as an alternative for sed is quite helpful. The command goes like this: perl -e "s/www\.hawaiifsbos\.com/test\.hawaiifsbos\.com/g;" -pi $(find . -type f) -p = will do a loop sequence. For more info, read the page in " Using the -n and -p option " -i = will modify file in-place. providing after the "i" letter with a word, will be used as a back-up suffix of a file. (Ex. -pi.bak) -e = means execute This is the same thing as find . -name "*.*" -type f -exec sed -i 's/www.mysite.com/test.mysite.com/g' {} \; The above works in my Slack, but it seems weird it doesn't do in FreeBSD, but the perl is there as my alternative.

rsync: avoid overwriting of files

I was migrating this stuffs we have from an old FreeBSD 4.0 Server to a new FreeBSD 6.0 Server hosted at Verio. I was fumbled and tumbled when I use this rsync tool by migrating the files to our new server. The situation is that, in every directories we have being assigned in a virtual host and its DocumentRoot are having different owners and group assigned. The old server we have is having a version of an old Apache . Now, in order to achieve the exact ruling or permission, rsync is a tool that enables you to preserve ownership as well as its permission of the files/directories that you're going to copy--or shall we use the term "migrate". My mistake was that, migrating with files using rsync is a little bit tricky. Ending a copy like this, for example: rsync -r -e "ssh -l ahkmed" localhost:/home/ahkmed/documents /www/documents is a different story than rsync -r -e "ssh -l ahkmed" localhost:/home/ahkmed/documents/ /www/documents Note the ending has s