954,135 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

grep '^[a-zA-Z]'

Hi everyone,

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

Cheers,

Toktam
Newbie Poster
5 posts since May 2007
Reputation Points: 10
Solved Threads: 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.

masijade
Industrious Poster
Moderator
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
 

^ 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,

vrgurav
Newbie Poster
11 posts since Jun 2007
Reputation Points: 10
Solved Threads: 1
 

^ 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,

vrgurav
Newbie Poster
11 posts since Jun 2007
Reputation Points: 10
Solved Threads: 1
 

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

vrgurav
Newbie Poster
11 posts since Jun 2007
Reputation Points: 10
Solved Threads: 1
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You