Hi everyone,

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

Cheers,

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.

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

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.