LinuxQuestions.org
Register a domain and help support LQ
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
 
LinkBack Search this Thread
Old 04-25-2009, 04: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 04:34 AM.
 
Old 04-25-2009, 08: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
Trackbacks are Off
Pingbacks are On
Refbacks are 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 07:18 PM
Perl question: delete line from text file with duplicate match at beginning of line mrealty Programming 7 04-01-2009 06:46 PM
text data conversion: rows into columns frankie_DJ Programming 6 06-03-2006 06:43 AM
deleting 100 rows in text file (1-100) via terminal itz2000 Linux - Newbie 5 01-17-2006 11:19 PM
How 2 find a duplicate word in a text file cowardnewbie Programming 1 09-16-2001 11:57 PM


All times are GMT -5. The time now is 10:34 PM.

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