LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Easy text merge... need help (https://www.linuxquestions.org/questions/linux-software-2/easy-text-merge-need-help-515449/)

MicahCarrick 01-01-2007 07:56 PM

Easy text merge... need help
 
I need to take a text file and create each line duplicated...

apple
orange
pear

should become

apple
apple
orange
orange
pear
pear

Anyone know what commands I should use off the top of their heads?

MicahCarrick 01-01-2007 07:57 PM

I'm sorry... actually, then need to be on the same line separated by a tab...

apple apple
orange orange
pear pear

much like the join command but without the column to join on.

chrism01 01-02-2007 12:45 AM

Try a variation on this page: http://www.thedumbterminal.co.uk/php...ion=view&id=41
basically match anything s/.*/\1 \1/ replace with itself twice. Not sure about tab, try \t in between \1\1

jlinkels 01-02-2007 04:58 AM

awk '{print $0 "\t" $0}' /path/to/yourfile

jlinkels

MicahCarrick 01-02-2007 12:30 PM

Thanks guys.


All times are GMT -5. The time now is 08:21 AM.