1,105,386 Community Members

grep '^[a-zA-Z]'

Member Avatar
Toktam
Newbie Poster
5 posts since May 2007
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi everyone,

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

Cheers,

Member Avatar
masijade
Industrious Poster
4,165 posts since Feb 2006
Reputation Points: 1,351 [?]
Q&As Helped to Solve: 510 [?]
Skill Endorsements: 22 [?]
Team Colleague
Featured
 
0
 

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

So, what the following pipeline command does

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.

Member Avatar
vrgurav
Newbie Poster
11 posts since Jun 2007
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

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

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

Hi everyone,


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

Cheers,

Member Avatar
vrgurav
Newbie Poster
11 posts since Jun 2007
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

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

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

Hi everyone,


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

Cheers,

Member Avatar
vrgurav
Newbie Poster
11 posts since Jun 2007
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

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

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article