grep question

bscott at ntisys.com bscott at ntisys.com
Fri Apr 18 16:49:02 EDT 2003


On 18 Apr 2003, at 4:37pm, jeff.macdonald at virtualbuilder.com wrote:
> How can I grep for \tfoobar\t?

  If you're using Bash, and it is an interactive shell, use single-quotes
and do a literal insert of a tab character by pressing [CTRL]+[V] followed
by [TAB].  The command will look like

	grep '        foobar        ' file

  If you are in a script file, use your editor to insert a literal character
in the script file.

  If you find the concept of inserting a literal tab character distasteful, 
you can use Perl (or pcregrep(1), if you have it):

	perl -ne 'print if m/\tfoobar\t/;' < file

	pcregrep '\tfoobar\t' file

  This is how I do it.  There may be better ways.

-- 
Ben Scott <bscott at ntisys.com>
| The opinions expressed in this message are those of the author and do  |
| not represent the views or policy of any other person or organization. |
| All information is provided without warranty of any kind.              |




More information about the gnhlug-discuss mailing list