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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
11-08-2004, 09:56 AM
|
#1
|
LQ Newbie
Registered: Oct 2003
Distribution: Gentoo
Posts: 8
Rep:
|
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.
|
|
|
11-08-2004, 10:02 AM
|
#2
|
Senior Member
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,994
Rep:
|
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: would list all files starting with t, and ending in a?.dat (where ? is any character).
Hope that helps,
—Robert J. Lee
|
|
|
11-08-2004, 10:36 AM
|
#3
|
LQ Newbie
Registered: Oct 2003
Distribution: Gentoo
Posts: 8
Original Poster
Rep:
|
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!
|
|
|
11-08-2004, 10:39 AM
|
#4
|
Senior Member
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,994
Rep:
|
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: Or to compress the catenation of each file listed in the file file.lst:
Code:
cat `cat file.lst` | bzip2
|
|
|
04-19-2005, 01:02 PM
|
#5
|
LQ Newbie
Registered: Apr 2005
Location: Colombia
Distribution: Slackware
Posts: 18
Rep:
|
I'm trying to concatenate two files but the output is not the one that one would expect
you have two files
one
two
then execute
Code:
cat one two >> three
then, result is
three
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.
|
|
|
04-20-2005, 02:14 PM
|
#6
|
LQ Newbie
Registered: Apr 2005
Location: Colombia
Distribution: Slackware
Posts: 18
Rep:
|
I'm still stuck,
I'm reusing this existing thread, to not disturb you too much.
Is there somebody reading that?
Andrés.-
|
|
|
04-21-2005, 03:29 PM
|
#7
|
Senior Member
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,994
Rep:
|
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
two
then execute
Code:
cat one two >> three
then, result is
three
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.)
|
|
|
04-21-2005, 08:33 PM
|
#8
|
LQ Newbie
Registered: Apr 2005
Location: Colombia
Distribution: Slackware
Posts: 18
Rep:
|
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.-
|
|
|
05-02-2005, 06:13 AM
|
#9
|
LQ Newbie
Registered: Oct 2003
Distribution: Gentoo
Posts: 8
Original Poster
Rep:
|
Use ''dd' command to chop files, and 'cat' to recombine them.
WP
|
|
|
05-02-2005, 02:47 PM
|
#10
|
LQ Newbie
Registered: Apr 2005
Location: Colombia
Distribution: Slackware
Posts: 18
Rep:
|
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.-
|
|
|
05-05-2005, 01:39 AM
|
#11
|
LQ Newbie
Registered: Oct 2003
Distribution: Gentoo
Posts: 8
Original Poster
Rep:
|
'dd. is part of coreutils too. And it can read form block devices, which I'm not sure 'split' does.
regards,
WP
|
|
|
All times are GMT -5. The time now is 03:38 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|