|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Vi - insert a tab between words?
I have several lines in a file that I want to replace a space with a tab.
For example: 111047 [tab] Julie Jones email@email.com 111047 [tab] Julie Jones [tab] email@email.com I want to replace the space after the word "jones" with a tab. How do I achieve that in Vi? Please assist. Thanks! |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
Run below in VI command mode:- Code:
:%s/Jones /Jones[tab]/g Note: press key: Tab (highlighted) after string: Jones for replacement. |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
So if i have multiple lines with different names, how do I achieve that?
Thanks much! |
|
#4
|
||||
|
||||
|
You can use awk instead to put a tab before last column email id:- Code:
awk ' { email=$NF; gsub(email,"\t"email,$NF); print $0 } ' input_file |
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
Do you know how I could also achieve this in Vi?
Thanks! |
| Sponsored Links | |
|
|
#6
|
|||
|
|||
|
try: Code:
:1,$s/ \([^ ]*@\)/\t\1/ |
| Sponsored Links | ||
|
![]() |
| Tags |
| space, tabs, vi |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| insert LF and TAB for formatting | dba_frog | Shell Programming and Scripting | 1 | 02-11-2011 09:35 AM |
| sed: how to insert tab? | Juha | Shell Programming and Scripting | 2 | 10-29-2007 07:15 AM |
| How to insert tab at specified column.HELP | sslr | UNIX for Dummies Questions & Answers | 7 | 09-21-2007 10:54 AM |
| pls help me to insert tab and formatthe file | getdpg | Shell Programming and Scripting | 5 | 02-02-2006 12:35 PM |
| Insert TAB in echo statement | sunils27 | Shell Programming and Scripting | 5 | 08-26-2005 03:36 AM |
|
|