Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19
finding a friggin tab with sed or grep
Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: finding a friggin tab with sed or grep

  1. #1

    finding a friggin tab with sed or grep

    Ok. Ive posted on about every linux forum i could find so far and no one seems to know the answer to this one: how in the blazes do you find a "tab" when using grep or sed? Here are some things ive already tried:
    grep '\t' filename
    grep '[:space:]' filename
    grep '[:tab:]' filename
    grep '<tab>' filename
    grep '(actually hitting tab here)' filename
    Ive also tried some slightly more cryptic things like creating a file with only a tab (we'll call the file "tab" here) and trying something like this:
    fgrep -f tab filename
    and sure enough that works for finding only a tab but i need to find a tab like in the middle of a regular expression and its driving me nuts! Yes, im aware that there are ways to get around specific instances of this by using a pipeline with awk (which does accept \t as a tab, btw) but i really need some way to reference *an actual tab when using sed or grep. My next option is to try using the ASCII code for a tab and see if that works. Does anyone know how to do that either? Thanks, and ill be 100% impressed if you know the answers to the questions. Thanks!!!!!

    --Morphman
    PS: i should also mention that im running Redhat 7.2.

  2. #2

    Re: finding a friggin tab with sed or grep

    I do not have access to a Linux box right now, but would the following work?

    egrep \t filename

    I know it works on AIX, but then it works with ordinary grep too.

    Also for GNU sed, I think you can enter a real tab if you precede it with a backslash. Again I can't test it so I might be lying

  3. #3

    Re: finding a friggin tab with sed or grep

    Nope, it doesnt work. Thanks though.

  4. #4

    Re: finding a friggin tab with sed or grep

    Here I am writing from the comfort of my own Linux box, all I can say is I'm stumped. Sorry :-[

  5. #5

    Re: finding a friggin tab with sed or grep

    Ok, I don't like to give up. This is one method....

    tb=`printf "\t"`
    grep "$tb" myfile

    As you can see, it works by loading a shell variable with the tab character and using that as the search pattern.

  6. #6
    Guest

    Re: finding a friggin tab with sed or grep

    Pam, you keep on impressing me..

  7. #7

    Re: finding a friggin tab with sed or grep

    Hmm, looks like it has potential ! im leaving work now so ill try it first thing tomorrow morning! Thanks! If it works in the middle of a regular expression ill be totally satisfied and you can take satisfaction in knowing that out of all of the forums ive posted on and all the linux people ive talked to, you would be the ONLY one who figured it out! For now, im going home, :P

  8. #8

    Re: finding a friggin tab with sed or grep

    Does it actually have to be a tab specifically?

    If so, you should try ^I (type CTRL-V and then CTRL-I). That ought to work, but untested.

    If you want to match spaces or tabs, use \s, which will match any whitespace as far as I know.

    HTH.

  9. #9

    Re: finding a friggin tab with sed or grep

    Actually, I just tested the ^I thing and it works. You're welcome

  10. #10

    Re: finding a friggin tab with sed or grep

    Well, Pam i tried your technique but it doesnt seem to be working. I see what you are doing but wouldnt typing:
    tb='printf "\t"'
    just load *<printf \t> into the variable tb and then typing:
    grep "$tb" filename *would in turn just say:
    grep "printf \t" filename ?
    im most likely doing something wrong if you got it to work. I tried doing exactly that and it didnt quite work. Im still a newbie so i need someone else to hold my hand and explain that one to me!
    Feztaa!! That worked PERFECTLY! That was exactly what i was looking for, some non-cryptic normal way to insert a tab into a normal expression. Thanks folks, you are awesome. I was beginning to believe id never have any closure to this problem. Ill be sticking with linuxjunior in the future! * WOOHOO!!

    --Morphman, exceptionally content linux newbie

    PS: you have no idea how helpful this is!!

    PS2: How did you find that Feztaa? Im always looking for more access to help tables and websites..


Similar Threads

  1. grep absolute path
    By svar in forum Linux - Software, Applications & Programming
    Replies: 1
    Last Post: 12-02-2010, 04:41 AM
  2. Using grep in my home directory
    By Clai2x in forum Linux - Software, Applications & Programming
    Replies: 0
    Last Post: 12-19-2007, 04:57 AM
  3. Using Grep and regex to pull a value out of a string
    By thestonefox in forum Linux - Software, Applications & Programming
    Replies: 1
    Last Post: 10-24-2007, 03:58 PM
  4. What does 'locate network grep howto' do?
    By Smegma in forum Linux - Software, Applications & Programming
    Replies: 7
    Last Post: 03-28-2004, 04:16 AM
  5. This is so Friggin FUNNY!!
    By in forum General Chat
    Replies: 2
    Last Post: 04-16-2003, 07:49 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •