Category Archives: Unix

Useful VI commands

Show line numbers
:set number

Replacing a text within a file in place

Recently I had to replace some text within a file, I also wanted this to occur in place. I ended up with two solutions. Mainly because of the Solaris version. But also because I wanted to play with Groovy again.

1. Perl on the commandline

perl -pi -e 's/1.2-SNAPSHOT/1.2/g' pom.xml

2. Using Groovy
Refer to Groovy: Writing to a File

Unix find and grep

Periodically I need to find some files within a unix server that contain some random text. I also get caught out between say Redhat or Solaris or OSX.

Recently it was searching for some text within a heap of maven pom files.

find . -name pom.xml | xargs grep '1.2-SNAPSHOT'

CURL Tutorial

I am always having to google a decent lookup on CURL.

Quick usage:

curl <url>