The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-03-2008
na5m's Avatar
na5m na5m is offline
Registered User
  
 

Join Date: Jun 2008
Location: Sacramento, CA
Posts: 15
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
  #2 (permalink)  
Old 07-04-2008
Annihilannic Annihilannic is offline Forum Advisor  
  
 

Join Date: May 2008
Location: Sydney, Australia
Posts: 1,009
Have you tried just using the tab key to enter the character in your sed script?
  #3 (permalink)  
Old 07-04-2008
na5m's Avatar
na5m na5m is offline
Registered User
  
 

Join Date: Jun 2008
Location: Sacramento, CA
Posts: 15
I tried that. However, when I hit the tab key, the PC speaker just beeps and the cursor stays where it was.
  #4 (permalink)  
Old 07-04-2008
Annihilannic Annihilannic is offline Forum Advisor  
  
 

Join Date: May 2008
Location: Sydney, Australia
Posts: 1,009
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 (permalink)  
Old 07-04-2008
na5m's Avatar
na5m na5m is offline
Registered User
  
 

Join Date: Jun 2008
Location: Sacramento, CA
Posts: 15
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 12:56 AM.. Reason: clarification
  #6 (permalink)  
Old 07-04-2008
Annihilannic Annihilannic is offline Forum Advisor  
  
 

Join Date: May 2008
Location: Sydney, Australia
Posts: 1,009
Oh, try Ctrl-V followed by the tab key.
  #7 (permalink)  
Old 07-04-2008
catwoman catwoman is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 6
You could try typing...

ctrl-v ctrl-i

..for the tab character. I find this works.
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 09:17 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0