1.11M Members

grep '^[a-zA-Z]'

 
0
 

Hi everyone,

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

Cheers,

 
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.

 
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,

 
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,

 
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 six months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article