The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
awk how to print if the search pattern contains speace McLan Shell Programming and Scripting 1 04-09-2008 09:39 AM
Shell script to search through numbers and print the output cdfd123 Shell Programming and Scripting 8 10-30-2007 04:40 PM
using awk to search and print output cdfd123 Shell Programming and Scripting 5 09-18-2007 05:00 AM
Can I search columns and print lines? Ant1815 UNIX for Dummies Questions & Answers 2 04-26-2007 07:01 AM
Search for text and print the next line alijassim Shell Programming and Scripting 2 08-17-2004 06:08 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-10-2008
orahi001 orahi001 is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 48
awk search and print .doc extensions

Hello,

I'm trying to grab all lines in a file that match the extension using the following command:

awk '/.doc/' Input.csv > WordFiles.dat

This works, but if a line contains "doc" it still prints the line. I want to print only the lines with ".doc"

Can someone show how to pick up only ".doc"

thanks
  #2 (permalink)  
Old 04-10-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
In a regular expression, just a dot means any character. Backslash it to get the literal meaning.

You might want to make the regular expression even more constrained (say, require there to be no alphabetic after the "doc").

awk is overkill, this is a typical grep problem.

Code:
grep '\.doc' input.csv >WordFiles.dat
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:53 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0