Friday, June 5, 2009

awk examples

awk examples:-

the global structure of an awk command is as follows:-

awk '/pattern/{action}' filename


displaying lines that contain a given pattern with awk

user@ubuntu:~$ awk '/root/' /etc/passwd
root:x:0:0:root:/root:/bin/bash

user@ubuntu:~$ awk '/root/{print $1}' /etc/passwd
root:x:0:0:root:/root:/bin/bash

No comments:

Post a Comment