The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



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 !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
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
text files, ASCII files, binary files and ftp transfers Perderabo Answers to Frequently Asked Questions 0 04-08-2004 05:25 PM
grep multiple text files in folder into 1 text file? coppertone UNIX for Dummies Questions & Answers 7 08-23-2002 03:50 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-03-2004
222001459 222001459 is offline
Registered User
  
 

Join Date: Nov 2004
Posts: 2
Post 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
  #2 (permalink)  
Old 11-03-2004
lgaxiola lgaxiola is offline
Registered User
  
 

Join Date: Nov 2004
Posts: 3
Hi

you can use:

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

example

file1
Hello

file2
Goodbye

cat file1 file2 > fileresult

fileresult
Hello
Goodbye
  #3 (permalink)  
Old 11-03-2004
zazzybob's Avatar
zazzybob zazzybob is offline Forum Advisor  
Registered Geek
  
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
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 (permalink)  
Old 05-05-2009
kti's Avatar
kti kti is offline
Registered User
  
 

Join Date: May 2009
Location: Hungary
Posts: 1
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)
  #5 (permalink)  
Old 11-03-2004
A452917 A452917 is offline
Registered User
  
 

Join Date: Nov 2004
Location: Mumbai, India
Posts: 14
Good suggestion ZB. But there is no other way than typing all the filenames if one needs to concatenate files in a specific order.
  #6 (permalink)  
Old 11-03-2004
zazzybob's Avatar
zazzybob zazzybob is offline Forum Advisor  
Registered Geek
  
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
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
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:15 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0