grep '^[a-zA-Z]'

Reply

Join Date: May 2007
Posts: 5
Reputation: Toktam is an unknown quantity at this point 
Solved Threads: 0
Toktam Toktam is offline Offline
Newbie Poster

grep '^[a-zA-Z]'

 
0
  #1
Jun 4th, 2007
Hi everyone,

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

Cheers,
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,639
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 283
Moderator
masijade's Avatar
masijade masijade is offline Offline
Posting Maven

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

 
0
  #2
Jun 6th, 2007
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.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 11
Reputation: vrgurav is an unknown quantity at this point 
Solved Threads: 1
vrgurav vrgurav is offline Offline
Newbie Poster

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

 
0
  #3
Jun 19th, 2007
^ indicate from begining of the line
[] indicates individual occurance

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




Originally Posted by Toktam View Post
Hi everyone,


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

Cheers,
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 11
Reputation: vrgurav is an unknown quantity at this point 
Solved Threads: 1
vrgurav vrgurav is offline Offline
Newbie Poster

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

 
0
  #4
Jun 19th, 2007
^ indicate from begining of the line
[] indicates individual occurance

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




Originally Posted by Toktam View Post
Hi everyone,


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

Cheers,
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 11
Reputation: vrgurav is an unknown quantity at this point 
Solved Threads: 1
vrgurav vrgurav is offline Offline
Newbie Poster

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

 
0
  #5
Jun 19th, 2007
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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Shell Scripting Forum


Views: 1704 | Replies: 4
Thread Tools Search this Thread



Tag cloud for Shell Scripting
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC