IT

awk Examples

ls -la |grep -i ‘opt’ | awk ‘{print $10}’ > //test.txt

Example of script that uses awk and includes 9th field and everything else on the line.

#!/bin/sh

[ -f /tmp/errlst ] && rm /tmp/errlst

./bperror | grep -i win32 >/tmp/errlst

while read line; do

A=`echo $line | awk ‘{for (i=9; i<=NF; i++) print $i}’` echo $A done < /tmp/errlst

Advertisements

Categories: IT, Unix Scripts

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