Computing.Net > Forums > Windows 95/98 > Problem with grep

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Problem with grep

Reply to Message Icon

Name: hoogcg
Date: December 19, 2005 at 13:21:24 Pacific
OS: HP-UX
CPU/Ram: Not relevent
Comment:

I'm trying to use the following command to give me a listing of all files that do NOT end in ".Z": ls | grep -v .Z
However, it is also excluding files that have a Z anywhere in the file name. I've tried enclosing the .Z in single and double quotes with no luck. Why does the grep command ignore the "."?



Sponsored Link
Ads by Google

Response Number 1
Name: Zenith
Date: December 19, 2005 at 13:49:27 Pacific
Reply:

This appears to be in the wrong forum - but -

grep interprets the "." as a wildcard for a single character match.

To do what you want, you have to use the escape (\) character like so:

ls | grep -v '\.Z'

http://pegasus.rutgers.edu/~elflord/unix/grep.html#wildcards

Internet search engines are your friends.

Morpheus: There is a difference between knowing the path and walking the path. "The Matrix"


0

Response Number 2
Name: DAVEINCAPS
Date: December 19, 2005 at 14:36:21 Pacific
Reply:

I'm not sure if you mean the file name can't end in Z or if it's extension can't be Z. (You specify they can't end in .Z instead Z.)

I believe ls | grep -v '.Z'

will ignore all files whose extension begins with Z.

Disclaimer: This is all new to me.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Windows 95/98 Forum Home


Sponsored links

Ads by Google


Results for: Problem with grep

Problem with shortcut www.computing.net/answers/windows-95/problem-with-shortcut/43515.html

problem with the java pages www.computing.net/answers/windows-95/problem-with-the-java-pages/46445.html

problems with my hd www.computing.net/answers/windows-95/problems-with-my-hd/35874.html