Concatenating Text Files | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Concatenating Text Files

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 11-03-2004
222001459 222001459 is offline
Registered User
 
Join Date: Nov 2004
Last Activity: 16 December 2004, 12:47 PM EST
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Java Concatenating Text Files

Hi,

I have 30 text files on UNIX that I need to concatenate and create one big file. Could anyone provide me with a solution (if one exist)? I need the answer asap (today). Thanks a lot.

Denis
Sponsored Links
    #2  
Old 11-03-2004
lgaxiola lgaxiola is offline
Registered User
 
Join Date: Nov 2004
Last Activity: 4 November 2004, 9:52 AM EST
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Hi

you can use:

cat file1 file2 file3...... fileN > added file.

example

file1
Hello

file2
Goodbye

cat file1 file2 > fileresult

fileresult
Hello
Goodbye
Sponsored Links
    #3  
Old 11-03-2004
zazzybob's Avatar
zazzybob zazzybob is offline Forum Advisor  
Registered Geek
 
Join Date: Dec 2003
Last Activity: 13 May 2013, 9:02 AM EDT
Location: Melbourne, Australia
Posts: 2,185
Thanks: 3
Thanked 24 Times in 23 Posts
Seeing as you have a lot of files it'd be quick to do something like

$ cd /path/to/files
$ files=*
$ cat $files > bigfile

Saves you typing all the filenames in. There are more ways to do this, but this is about the quickest and easiest.

Cheers
ZB
    #4  
Old 11-03-2004
A452917 A452917 is offline
Registered User
 
Join Date: Nov 2004
Last Activity: 6 July 2005, 3:34 PM EDT
Location: Mumbai, India
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Good suggestion ZB. But there is no other way than typing all the filenames if one needs to concatenate files in a specific order.
Sponsored Links
    #5  
Old 11-03-2004
zazzybob's Avatar
zazzybob zazzybob is offline Forum Advisor  
Registered Geek
 
Join Date: Dec 2003
Last Activity: 13 May 2013, 9:02 AM EDT
Location: Melbourne, Australia
Posts: 2,185
Thanks: 3
Thanked 24 Times in 23 Posts
Quote:
Originally posted by A452917
Good suggestion ZB. But there is no other way than typing all the filenames if one needs to concatenate files in a specific order.
Indeed - but this wasn't a criteria set out in the original post.

I also have a wee suspicion that this whole thing is a homework post anyway "I need the answer asap (today)" - hmmm

Cheers
ZB
Sponsored Links
    #6  
Old 05-05-2009
kti's Avatar
kti kti is offline
Registered User
 
Join Date: May 2009
Last Activity: 13 May 2009, 12:43 AM EDT
Location: Hungary
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Question

zazzybob!
Your answer (found via Google search) is a great help to me, thanks.

$ cd /path/to/files
$ files=*
$ cat $files > bigfile

I modified it like that:

$ cd /path/to/files
$ files=*.txt
$ cat $files > bigfile.txt

How could I insert in front of the content of each file some special string, like many dashes, and / or the given file's name?

So, the bigfile.txt looked like this:

********* file1.txt
content of file1

********* file2.txt
content of file2

********* file3.txt
content of file3
...
...
etc

Thanks a lot,

Tamas
(I use Kubuntu, by the way)
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Concatenating two files Sriramprabu Shell Programming and Scripting 6 09-16-2008 12:33 AM
negatively concatenating files raidzero Shell Programming and Scripting 2 07-10-2008 04:52 PM
Concatenating records from 2 files Powcmptr UNIX for Dummies Questions & Answers 4 04-02-2008 04:57 PM
concatenating x files into a one... Nicol UNIX for Dummies Questions & Answers 1 09-30-2004 09:13 AM



All times are GMT -4. The time now is 07:54 PM.