sed imbed a tab


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sed imbed a tab
# 1  
Old 07-04-2008
sed imbed a tab

I'm using OpenBSD 4.3 & ksh (pdksh) default shell.
I'm trying to use sed to insert a tab into a text file with no luck.
Code:
$ sed 's/SusanAppleton/Susan\o011Appleton/' myFile.txt
Susano011Appleton
$ sed 's/SusanAppleton/Susan\tAppleton/' myFile.txt
SusantAppleton

I'm close to suicide here. Please help Smilie
# 2  
Old 07-04-2008
Have you tried just using the tab key to enter the character in your sed script?
# 3  
Old 07-04-2008
I tried that. However, when I hit the tab key, the PC speaker just beeps and the cursor stays where it was.
# 4  
Old 07-04-2008
How weird.... is that when you're in vi? Or on the command-line? Or everywhere?

How about using perl instead:

Code:
perl -pe 's/SusanAppleton/Susan\tAppleton/' myFile.txt > myFile_modified.txt

# 5  
Old 07-04-2008
The tab key will beep the PC speaker when I try to use it in a command (however, tab completion works, oddly enough). When I'm using ed or vi, the tab key functions as expected (it inserts 0x09). I could definitely use perl, but I'd like to know why OpenBSD sed isn't working for me here. It's driving me crazy. GNU sed will allow \t \n etc...

Last edited by na5m; 07-04-2008 at 01:56 AM.. Reason: clarification
# 6  
Old 07-04-2008
Oh, try Ctrl-V followed by the tab key.
# 7  
Old 07-04-2008
You could try typing...

ctrl-v ctrl-i

..for the tab character. I find this works.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

SED - Unable to replace with <tab>

Hello All, I have this file with the below contents 1|2|3|4| this|that|which|what| when I use, sed 's/|/\t/g' infile I get, 1t2t3t4t thistthattwhichtwhatt Why is this?? :confused: :wall: (13 Replies)
Discussion started by: PikK45
13 Replies

2. Shell Programming and Scripting

Delete string between 3rd tab and first pattern with SED

Hello, I have this sentence :Pattern1 Pattern2 Pattern3 Pattern4-which-contains-HELLO-string-and-other-stuff-and-second-HELLO-and-third-HELLO I want to delete everything between the 3rd tab (\t) and the FIRST pattern "HELLO" of the line. Result expected is : Pattern1 ... (7 Replies)
Discussion started by: theclem35
7 Replies

3. Shell Programming and Scripting

How to remove tab space and new line from a file using sed?

i am using the default sed package that comes with solaris. (11 Replies)
Discussion started by: chidori
11 Replies

4. Shell Programming and Scripting

Using sed on 1st column of tab delimited file

Hi all, I'm new to Unix and work primarily in bioinformatics. I am in need of a script which will allow me to replace "1" with "chr1" in only the first column of a file which looks like such: 1 10327 rs112750067 T C . PASS ASP;RSPOS=10327;... (4 Replies)
Discussion started by: Hkins552
4 Replies

5. Shell Programming and Scripting

sed newline to tab ,problem

Input: gstreamer-plugins-good gstreamer-plugins-bad gstreamer-plugins-ugly sed 's/\n/\t/g' infile It's not working. Output should be: gstreamer-plugins-good gstreamer-plugins-bad gstreamer-plugins-ugly (5 Replies)
Discussion started by: cola
5 Replies

6. Shell Programming and Scripting

Conditional tab replacement sed/awk

Hi I am struggling to find a solutions to this problem: I have a directory full of files and I wish to: read each line of each file and if any one line in those files is longer than 72 characters I want to replace any tab characters with a space character. Ive been... (3 Replies)
Discussion started by: benackland
3 Replies

7. Shell Programming and Scripting

how to replace new line ( \n ) with space or Tab in Sed

Hi, how to replace new line with tab in sed ... i used sed -e 's/\n/\t/g' <filename > but its not working (1 Reply)
Discussion started by: mail2sant
1 Replies

8. UNIX for Dummies Questions & Answers

Tab spaces with sed

Anyone know how to represent tabs when doing subsitutions in sed? I have tried using \t but it doesn't seem to work. (11 Replies)
Discussion started by: handak9
11 Replies

9. UNIX for Dummies Questions & Answers

why the <tab> could be not recognized in grep and sed?

I try to remove empty lines from file and use next: > cat fl.dat|grep -v '^*$' or cat fl.dat|sed '/^*$/d' 'grep' does not removes lines with tabs, 'sed' - lines with <tab> and with <spc> Why it could be? Is there any option/env-var should I check? Thank you Alex (5 Replies)
Discussion started by: alex_5161
5 Replies

10. Shell Programming and Scripting

sed: how to insert tab?

Hi, I'm using the following to insert lines into file: sed ${rowNr}i'\ first row\ second row\ third row\ ' file.txt How can I add tab in front of each added line? "\t" or actual TAB does not seem to work? Thanks! (2 Replies)
Discussion started by: Juha
2 Replies
Login or Register to Ask a Question