awk to find a substring

This is pretty simple when you see it but took me a few minutes to figure it out:
The API is here: http://people.cs.uu.nl/piet/docs/nawk/nawk_92.html

$ export steo=D:\/dev_future\/
$ awk 'BEGIN { print substr("'$steo'", 3) }'
/dev_future/

The gotcha for me was the “‘$steo'” bit to read the environment variable. Easy if you know the syntax!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s