LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-08-2004, 09:56 AM   #1
cobra7x
LQ Newbie
 
Registered: Oct 2003
Distribution: Gentoo
Posts: 8

Rep: Reputation: 0
Combining files into one


Hi,
Is there any way to combine a number of files into one, by means of creating some kind of reference file or link? Is there any single command to accomplish this? Thanks for help in advance.
 
Old 11-08-2004, 10:02 AM   #2
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,994

Rep: Reputation: 76
If you want to append a group of files to each other, look at the command cat.
If you want to put a number of files into an archive, use tar or zip.

From your question, it looks like what you are wanting to do is to create a soft reference to a number of files, i.e. a file containing the filenames of the various files you want to link to. The easiest way to achieve this would be to use a plain text (or even XML) document containing the filenames — but that rather depends on how you want to use it.

If a program accepts multiple filenames on the command-line, then you can also use filename globbing; e.g:
Code:
ls t*a?.dat
would list all files starting with t, and ending in a?.dat (where ? is any character).

Hope that helps,

—Robert J. Lee
 
Old 11-08-2004, 10:36 AM   #3
cobra7x
LQ Newbie
 
Registered: Oct 2003
Distribution: Gentoo
Posts: 8

Original Poster
Rep: Reputation: 0
I rather meant a method of concatenating files so that they APPEAR (from file system point of view) as regular file, while being only link to other files.
The point is not to use 'cat' or whatever else to create a new file.

Thanks for your concern and immediate response!
 
Old 11-08-2004, 10:39 AM   #4
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,994

Rep: Reputation: 76
Why do you want to do this?
The usual approach is to concatenate the files as they are used. e.g., to print a set of all the *.tex files catenated:
Code:
cat *.tex | lpr
Or to compress the catenation of each file listed in the file file.lst:
Code:
cat `cat file.lst` | bzip2
 
Old 04-19-2005, 01:02 PM   #5
andresv
LQ Newbie
 
Registered: Apr 2005
Location: Colombia
Distribution: Slackware
Posts: 18

Rep: Reputation: 0
I'm trying to concatenate two files but the output is not the one that one would expect

you have two files

one
Code:
Hello W
two
Code:
orld
then execute

Code:
cat one two >> three
then, result is

three
Code:
Hello W
orld
And what I want is "Hello World" (without the CR)

Can somebody tell me what I'm doing wrong?

Is there another way of joining files? (with coreutils)

Is 'cat' binary-safe?

Thanks for the help.
 
Old 04-20-2005, 02:14 PM   #6
andresv
LQ Newbie
 
Registered: Apr 2005
Location: Colombia
Distribution: Slackware
Posts: 18

Rep: Reputation: 0
I'm still stuck,
I'm reusing this existing thread, to not disturb you too much.

Is there somebody reading that?

Andrés.-
 
Old 04-21-2005, 03:29 PM   #7
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,994

Rep: Reputation: 76
Quote:
Originally posted by andresv
I'm trying to concatenate two files but the output is not the one that one would expect

you have two files

one
Code:
Hello W
two
Code:
orld
then execute

Code:
cat one two >> three
then, result is

three
Code:
Hello W
orld
And what I want is "Hello World" (without the CR)

Can somebody tell me what I'm doing wrong?

Is there another way of joining files? (with coreutils)

Is 'cat' binary-safe?

Thanks for the help.
It looks like you have a newline at the end of the one file. (Some text editors add newlines for you). You didn't say how you generated the one and two files, but here's one way to do this example properly:
Code:
echo -n "Hello W" > one
echo -n "orld" > two
cat one two
Without the -n option, echo adds a newline to the end of its output.

cat is the lowest level core utility to catenate files. It is completely binary safe. It stops at the end of the file or stream, regardless of the EOF character, and does not mangle any permitation of CR and LF characters. (But the virtual terminal does, in case that's confusing you.)
 
Old 04-21-2005, 08:33 PM   #8
andresv
LQ Newbie
 
Registered: Apr 2005
Location: Colombia
Distribution: Slackware
Posts: 18

Rep: Reputation: 0
Thanks *rjlee* ... I was using cat >> one to create the file ...

And now with 'echo' works

My "real" problem is the next ...

I'm downloading iso images from an Internet Coffee ... they run win so can't use 'split' to chop the files in small pieces (to carry in my 256 MiB flash) so... i use a small program called 'Hacha' ( hacha.org ) -hacha stands for axe in spanish- but when I join the files with 'cat' they don't work I think Hacha write his own data in the pieces... (you can join with hacha too).

The question will be ... someone knows a win software that do the same that 'split' in *nix ... googling I found that "GNU utilities for Win32" ( unxutils.sf.net ) let's see if it works the next time I visit the Coffee

Bye.

Andrés.-
 
Old 05-02-2005, 06:13 AM   #9
cobra7x
LQ Newbie
 
Registered: Oct 2003
Distribution: Gentoo
Posts: 8

Original Poster
Rep: Reputation: 0
Use ''dd' command to chop files, and 'cat' to recombine them.

WP
 
Old 05-02-2005, 02:47 PM   #10
andresv
LQ Newbie
 
Registered: Apr 2005
Location: Colombia
Distribution: Slackware
Posts: 18

Rep: Reputation: 0
is dd a windows command ? ... I will try it ...

The port of the GNU coreutils for win32 ( unxutils.sf.net ) works fine

split in windows then cat

... And is faster than hacha (the so called "fastest splitter in the world!") ... yes maybe is the fastest but for windows (and with a GUI ...)

Thanks cobra7x

Andres V.-
 
Old 05-05-2005, 01:39 AM   #11
cobra7x
LQ Newbie
 
Registered: Oct 2003
Distribution: Gentoo
Posts: 8

Original Poster
Rep: Reputation: 0
'dd. is part of coreutils too. And it can read form block devices, which I'm not sure 'split' does.

regards,
WP
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Combining Debian iso files to DVD Kilahchris Linux - Newbie 6 05-02-2006 03:04 AM
combining multiple rar files jollyjoice Linux - Newbie 2 04-02-2005 02:49 PM
Combining text files ebiven Linux - General 12 07-22-2004 11:13 AM
Combining Files GameboyHippo Linux - Newbie 4 09-25-2003 01:38 PM
combining mpeg files plisken Programming 0 03-04-2002 04:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:38 AM.

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
Open Source Consulting | Domain Registration