Mailing List Archive
tlug.jp Mailing List tlug archive tlug Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]Re: [tlug] Sed question
- Date: Mon, 17 Feb 2003 19:00:40 +0900
- From: Matt Doughty <wyndigo@example.com>
- Subject: Re: [tlug] Sed question
- References: <20030217165947.2daf96c8.plate@example.com> <20030217082752.68199.qmail@example.com>
- User-agent: Mutt/1.4i
On Mon, Feb 17, 2003 at 12:27:52AM -0800, Matt Gross wrote: > I'm looking a quick sed fix to a problem I'm faced > with. I have a file with many lines of data. What I > need to do is concatenate the second line to the end > of the first line. That's all. Does anyone know how > this can easily be done with sed? Is there an easier > way to do this other than sed? > You can use a combination of tr and sed to do the magic, but I don't think it is the best solution[1], but here it is regardless: cat <file.txt> | tr "\n" "^G" | sed -e 's/^G/ /' | tr "^G" "\n" This is needed because sed "wisely" strips the \n before processing and tacks it back on after its finish. Then to make things worse it doesn't include a join range function. Its exactly things like this that led to awk and perl, and we are all better for them.[2] --Matt [1] this solution assumes that you don't have actual ^G enbedded in the text and you have to use (ctl-v ctl-g) to create the control chars so the substition will work. [2] though I know some might violently disagree with in reference to perl. What ya going to do though?
- References:
- [tlug] Unbreakable Oracle...
- From: Ulrich Plate
- [tlug] Sed question
- From: Matt Gross
Home | Main Index | Thread Index
- Prev by Date: Re: [tlug] using a cross-cable
- Next by Date: [tlug] test
- Previous by thread: Re: [tlug] Sed question
- Next by thread: [tlug] iptables: do these rules cut it?
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links