[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: grep command and options

From: Charles Swiger
Subject: Re: grep command and options
Date: Thu, 8 Jul 2010 15:33:16 -0700


On Jul 8, 2010, at 6:38 AM, Anil Kapoor wrote:
> I am trying to read a contents of a file through grep command, if for e.g
> 1st line of my file contains *:MB680*  i want to read just MB680 not* :(*
> colon)

Taking you very literally:

% echo '*:MB680*' > /tmp/testfile.txt
% grep \: /tmp/testfile.txt | cut -b 3-

...however, I suspect you have a file which is using colons as a field 
separator, and you want the second column, in which case awk is probably a 
better choice:

% awk -F\: '{print $2}' /tmp/testfile.txt


reply via email to

[Prev in Thread] Current Thread [Next in Thread]