Inline text replacement with sed

Replacing values in files is incredibly easy with sed. Here’s some examples:

 

sed 's/match/replace/g' file.txt

Find match, replace with replace, globally (all matches), in file.txt

 

sed 's/match/replace/g' file.txt > file2.txt

Same as before, but write results to new file, file2.txt

 

sed -n 's/match/replace/p' file.txt

-n suppresses output of the results, but /p prints out just the matching patterns that are replaced.

 

sed -i.old 's/match/replace/g' file.txt

Replace matches in the input file with inline replace (-i), renaming original file file.txt.old and writing inline replace results to file.txt

 

Taking screenshots on Raspbian / Raspberry Pi

Install scrot (if not already installed): sudo apt-get install scrot

To pick a window, run ‘scrot -s’ and then click on the window that you want to capture. Screenshot is saved in your home dir by default.

 

AngularJS form validation and ng-messages

I’ve been working on a simple example AngularJS app uses ng-messages. Code so far is on my github here.

This is part of my ongoing activity learning AngularJS. You can see my other posts and progress so far here.

To get up to speed with ngMessages, there’s a great tutorial here, and online docs here.