LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 04-25-2009, 05:33 AM   #1
guest
Member
 
Registered: May 2003
Distribution: CentOS 5 64 bit
Posts: 255

Rep: Reputation: 30
How to duplicate rows of text from one file to another?


So one of the file has this:

input.txt
a
b
c
d

how do you create this?

output.txt
a
b
c
d
a
b
c
d
a
b
c
d

there's gotta be a simple one liner that can get this done quickly.

Thanks in advance!

Last edited by guest; 04-25-2009 at 05:34 AM.
 
Old 04-25-2009, 09:14 AM   #2
Robhogg
Member
 
Registered: Sep 2004
Location: Old York, North Yorks.
Distribution: Debian 7 (mainly)
Posts: 653

Rep: Reputation: 85
How about:
Code:
cat input.txt input.txt input.txt > output.txt
... or:
Code:
c=0; while [ c -lt 3 ]; do cat input.txt >> output.txt; \
c=$((c + 1)); done
For more, see The Rute Users' Guide.
 
  


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
Print only specific rows in a text file Mike_V Programming 3 04-24-2009 08:18 PM
Perl question: delete line from text file with duplicate match at beginning of line mrealty Programming 7 04-01-2009 07:46 PM
text data conversion: rows into columns frankie_DJ Programming 6 06-03-2006 07:43 AM
deleting 100 rows in text file (1-100) via terminal itz2000 Linux - Newbie 5 01-18-2006 12:19 AM
How 2 find a duplicate word in a text file cowardnewbie Programming 1 09-17-2001 12:57 AM


All times are GMT -5. The time now is 06:24 PM.

Main Menu
Advertisement
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