Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Match whole word using grep 1

Status
Not open for further replies.

Michael42

Programmer
Oct 8, 2001
1,454
US
I am trying to grep the /etc/vfstab file to determine the partitions to backup. If I do this:

grep -i /usr /etc/vfstab

I also get my data partitions (/usr1, /usr2 ...). (-:

Please give me an example of doing a grep for just /usr but making sure it does not match /usr1 also.

Thanks for your advice,

Michael42
 
Hi:

Does

grep "^/usr$" /etc/vfstab

work?

Regards,


Ed
 
How about:

grep "/usr " /etc/vfstab

the above solution only matches '/usr' if on a line by itself.

-jim
 
This works great: grep "/usr " /etc/vfstab

Not sure why this does not work for me: grep "^/usr$" /etc/vfstab


Thanks all very much for your advice!

Michael42
 

How 'bout
grep "^\/usr[^0-9] " /etc/vfstab

the [^0-9] meaning "Not 0 through 9"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top