LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 06-28-2004, 04:06 AM   #1
iluvatar
Member
 
Registered: Jul 2003
Location: netherlands
Distribution: debian
Posts: 403

Rep: Reputation: 30
sed command to insert tab?


Hello everybody,

I need a simple sed script wich has to replace "BESCH<tab>112" with "BESCH<tab>102". sed detects the <tab> with [[:space:]] but how do I insert a tab in the replacement string?

Greetingz,
.-=~ iluvatar ~=-.
 
Old 06-28-2004, 04:29 AM   #2
arvind_sv
Member
 
Registered: Oct 2002
Location: Bangalore
Distribution: Gentoo Linux
Posts: 96

Rep: Reputation: 15
sed 's/^\(BESCH[[:space:]]\).*$/\1102/'

Arvind
 
Old 06-28-2004, 04:48 AM   #3
iluvatar
Member
 
Registered: Jul 2003
Location: netherlands
Distribution: debian
Posts: 403

Original Poster
Rep: Reputation: 30
Thanx, works perfectly although I don't know why... I have to read more about this...

greetz,
.-=~ iluvatar ~=-.
 
Old 06-28-2004, 09:29 AM   #4
arvind_sv
Member
 
Registered: Oct 2002
Location: Bangalore
Distribution: Gentoo Linux
Posts: 96

Rep: Reputation: 15
sed 's/^\(BESCH[[:space:]]\).*$/\1102/'

^ - Beginning of line.
\( - Start saving till corresponding \)
BESCH[[:space:]] - Pattern
\) - End save. Saved as \1 as it's the first pattern.
.*$ - Everything till end of line.
/ - End pattern, start action.
\1 - Put in first saved pattern (which is BESCH followed by a space)
102 - Put this in too.

Arvind
 
Old 06-29-2004, 01:56 AM   #5
iluvatar
Member
 
Registered: Jul 2003
Location: netherlands
Distribution: debian
Posts: 403

Original Poster
Rep: Reputation: 30
Thanks! sed seems to be much more complicated AND much better than I thought It's great to have this community too.

greetz,
.-=~ iluvatar ~=-.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sed: insert a newline. Why does not it work? J_Szucs Linux - Software 4 03-19-2014 01:28 PM
Insert CRLF's with sed? unSpawn Programming 6 11-22-2006 07:46 AM
insert string with sed greg108 Programming 7 02-18-2005 01:11 PM
insert a symbol with sed tonton Programming 5 08-31-2004 11:33 AM
Insert character into a line with sed? & variables in sed? jago25_98 Programming 5 03-11-2004 06:12 AM


All times are GMT -5. The time now is 02:50 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration