Find the answer to your Linux question:
Results 1 to 6 of 6
Hi, how do I copy two files into one file? In *BLEH* windows/dos it can be: copy /B source1 + source2 destination /B [B for binary] (I could not make ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jun 2006
    Posts
    3

    How to copy two files into one?


    Hi,

    how do I copy two files into one file?
    In *BLEH* windows/dos it can be:

    copy /B source1 + source2 destination /B [B for binary]

    (I could not make dd or cp do it)

    Thanx

  2. #2
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Slackware, {Free, Open, Net}BSD, Solaris
    Posts
    1,283
    Hi, LinuxUserToBe.

    The name of utility cat is short for [con]catenate; see man cat ... cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

  3. #3
    Just Joined!
    Join Date
    Jun 2006
    Posts
    3
    Hi!

    ...thanx for the answer and for the quick reply!

  4. #4
    Linux Engineer Zelmo's Avatar
    Join Date
    Jan 2006
    Location
    Riverton, UT, USA
    Posts
    1,001
    Well, that's half the answer. For the other half, you need to know about redirection.
    The greater-than (>) symbol is used to redirect input to a given output. For example,
    Code:
    $ cat file1 > newfile
    will put the contents of file1 into newfile, instead of printing it to the screen.

    In your case, what you want is the append symbol (>>). It will take the input and attach it to the end of a given file. So,
    Code:
    $ cat file1 file2 >> newfile
    put the contents of file1 and file2 together into newfile. Conveniently, newfile doesn't need to exist before you give the command--cat will make it for you. Of course, if it does exist already, then file1 and file2 will just get appended to the end of it.
    Stand up and be counted as a Linux user!

  5. #5
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Slackware, {Free, Open, Net}BSD, Solaris
    Posts
    1,283
    Hi, Zelmo.

    Thanks for extending my reply ... cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

  6. #6
    Just Joined!
    Join Date
    Jun 2006
    Posts
    3
    Hi Zelmo,

    and thanx for the info.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •