Find the answer to your Linux question:
Results 1 to 9 of 9
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie Andy_Crowd's Avatar
    Join Date
    Sep 2013
    Location
    日不落
    Posts
    121

    Question How to Insert TAB(tabulator) Automaticaly?


    Hi!

    I have a text that looks like:

    fskdsaljdlk $$ sdfbsd
    sdfl $$ sdfnskd
    ksadasdkj$$ asdnkjas

    But I need that it will look like:

    fskdsaljdlk
    $$ sdfbsd
    sdfl
    $$ sdfnskd
    ksadasdkj
    $$ asdnkjas

    But all should be on the same line.

  2. #2
    Super Moderator Roxoff's Avatar
    Join Date
    Aug 2005
    Location
    Nottingham, England
    Posts
    4,087
    It depends what you're using to do this with. I suspect there is some kind of script language that you're using, not just a text editor?

    Generally you'd get the script to insert a tab character where you want your tab to appear, that's normally a literal '\t'. How you come to insert it depends on the script and the scripting language you use.
    Linux user #126863 - see http://linuxcounter.net/

  3. #3
    Linux Newbie Andy_Crowd's Avatar
    Join Date
    Sep 2013
    Location
    日不落
    Posts
    121
    I need to do it in a text file if possible, but in other application will be good too. I have mixed up rows because without tabs and many files and I want make a good looking rows for an easy overview.

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Newbie
    Join Date
    Jan 2013
    Location
    Argentina
    Posts
    124
    In the case of the text file with notes / etc. with no other purpose? Tabs can be done in vi' s / vim' s insert mode just by pressing the Tab key. I use it for the groceries list and works great. LOL.

  6. #5
    Linux Guru
    Join Date
    Dec 2013
    Location
    Victoria, B.C. Canada
    Posts
    2,103
    Code:
    sed 's/\$\$/\t$$/' your_file > your_new_file

  7. #6
    Quote Originally Posted by gregm View Post
    Code:
    sed 's/\$\$/\t$$/' your_file > your_new_file
    Don't we need back slashes before the dollar signs following the \t? As follows: sed 's/\$\$/\t\$\$/' I may be incorrect, but we don't want to interpret the $$ as a regular expressions.

  8. #7
    Linux Guru
    Join Date
    Dec 2013
    Location
    Victoria, B.C. Canada
    Posts
    2,103
    It's not matching output so, no, you don't need to escape the $.

  9. #8
    Ok, thanks. I really wasn't sure. --dsoliver

  10. #9
    Just Joined!
    Join Date
    Feb 2009
    Location
    USA
    Posts
    21
    -->
    Quote Originally Posted by Andy_Crowd View Post
    Hi!

    I have a text that looks like:

    fskdsaljdlk $$ sdfbsd
    sdfl $$ sdfnskd
    ksadasdkj$$ asdnkjas

    But I need that it will look like:

    fskdsaljdlk
    $$ sdfbsd
    sdfl
    $$ sdfnskd
    ksadasdkj
    $$ asdnkjas

    But all should be on the same line.
    The key here is your post title. How to insert a tab automatically.

    The key to the answer relies on another question: "What editor are you using?" If you are using OO3 or LibreOffice or Word - the answers are different. If you are using all command-line interface editors - the answer may be different for each one.

    I'm not telling you this to be a p.i.t.a., but we really need a bit more information (unless we guess correctly what you are thinking) about what you are doing.

    Things like:

    What are you writing the text with?
    Are you getting the text from an outside source and re-formatting?
    What is your objective when inserting the tab?

    Maybe a couple of other questions, but my brain just quit.

    But see, the possibilities are multitude.

    Cheers;
    M

Posting Permissions

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