Bash: page 1
Search and replace with confirmation in Bash
Automated search and replace can be very handy although there are occasions where a human needs to get involved on some of the decisions. If the search term isn’t unique or appears as part of other words or something like that. When this is the case you’ll want a confirm step where you can approve each replacement before it happens. With very little work we can achieve this using a combination of vim and grep. Read more ⇒
Email me when the file changes
It is important to ensure that Google does not index sites whilst they are still on a staging environment, but you cannot lock it down completely - how would your clients proof it? So I run a simple global rewrite rule in Apache that redirects all requests for robots.txt to a central disallow all response. This works great and Google appears to honour the rule as one would hope. What happens though when something about that central file changes? Read more ⇒
Scraping websites with wget and httrack
Scrapes can be useful to take static backups of websites or to catalogue a site before a rebuild. If you do online courses then it can also be useful to have as much of the course material as possible locally. Another use is to download HTML only ebooks for offline reading. There are two ways that I generally do this - one on the command line with wget and another through the GUI with httrack. Read more ⇒
Crop and resize images with bash and ImageMagick
Not wanting to repeat myself I have written a small bash script to handle the parallel processing of the post images for this site. This involves resizing, cropping and then compressing the images ready for the web. Currently the script supports both JPEG and PNG images for all these operations. On top of this I wanted to ensure that only recently added or modified images would be processed rather than processing the entire folder again. Read more ⇒