943,879 Members | Top Members by Rank

Ad:
Jun 4th, 2007
0

grep '^[a-zA-Z]'

Expand Post »
Hi everyone,

What does this command mean?
grep '^[a-zA-Z]'

Cheers,
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Toktam is offline Offline
5 posts
since May 2007
Jun 6th, 2007
0

Re: grep '^[a-zA-Z]'

I assume this is coming after some other command, right? Such as cat somefile.

So, what the following pipeline command does
Shell Scripting Syntax (Toggle Plain Text)
  1. cat somefile | grep "^[a-zA-Z]"
is return all lines that start with a letter, whether capital or not. Effectivly filtering out all lines that do not.

That is, as long as it is double quotes (") that are used. I believe that if it is single quotes (') are used, that it will only return those lines that contain (anywhere in the line) exactly those characters. I do not have a *nix system at hand, currently, to check that again though, and it has been a while since I have been able to work extensivly on an *nix system.
Moderator
Reputation Points: 1471
Solved Threads: 490
Industrious Poster
masijade is offline Offline
4,043 posts
since Feb 2006
Jun 19th, 2007
0

Re: grep '^[a-zA-Z]'

^ indicate from begining of the line
[] indicates individual occurance

hence it will display all the lines having haracter between A-Z or a-z




Click to Expand / Collapse  Quote originally posted by Toktam ...
Hi everyone,


What does this command mean?
grep '^[a-zA-Z]'

Cheers,
Reputation Points: 10
Solved Threads: 1
Newbie Poster
vrgurav is offline Offline
11 posts
since Jun 2007
Jun 19th, 2007
0

Re: grep '^[a-zA-Z]'

^ indicate from begining of the line
[] indicates individual occurance

hence it will display all the lines having character between A-Z or a-z




Click to Expand / Collapse  Quote originally posted by Toktam ...
Hi everyone,


What does this command mean?
grep '^[a-zA-Z]'

Cheers,
Reputation Points: 10
Solved Threads: 1
Newbie Poster
vrgurav is offline Offline
11 posts
since Jun 2007
Jun 19th, 2007
0

Re: grep '^[a-zA-Z]'

cat somefile | grep "^[a-zA-Z]"

it will direct the output of first command
ie cat somefile to grep command
and grep will give from first column of somefile all data having character between A-Z or a-z
Reputation Points: 10
Solved Threads: 1
Newbie Poster
vrgurav is offline Offline
11 posts
since Jun 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Shell Scripting Forum Timeline: rm command
Next Thread in Shell Scripting Forum Timeline: read line is stripping leading spaces





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC