Site Map - skip to main content - dyslexic font - mobile - text - print

Hacker Public Radio

Your ideas, projects, opinions - podcasted.

New episodes Monday through Friday.


hpr0787 :: Grep for tab

<< First, < Previous, Latest >>

Host Image
Hosted by Ken Fallon on 2011-08-08 is flagged as Explicit and is released under a CC-BY-SA license.
Listen in ogg, spx, or mp3 format. | Comments (1)

In todays summer short Ken tells us about how you can grep for a tab in a file.
grep "first{ctrl+v}{tab}second" file.txt

for more information see http://www.linuxquestions.org/questions/linux-newbie-8/tab-in-bash-script-242400/#post4386714


Comments

Subscribe to the comments RSS feed.

Comment #1 posted on 2011-08-26T17:01:18Z by Krayon

Another way (in BASH)

Another way you can do this would be use the special $'string' expansion which is treated specially and expands string with backslash-escaped characters replaced as specified by the ANSI C standard (see under QUOTING of the bash(1) man page for more info).

You could therefore do something like this:
grep "first"$'\t'"second" file.txt

This is also REALLY useful for weird characters (it supports \nnn, \U (unicode)) etc and the like.

Leave Comment

Note to Verbose Commenters
If you can't fit everything you want to say in the comment below then you really should record a response show instead.

Note to Spammers
All comments are moderated. All links are checked by humans. We strip out all html. Feel free to
record a show about yourself, or your industry, or any other topic we may find interesting. We also check shows for spam :).

Provide feedback
Your Name/Handle:
Title:
Comment:
Anti Spam Question: What does the P in HPR stand for ?
Are you a spammer →
Who hosted this show →
What does HPR mean to you ?