Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Concatenation of Files 1

Status
Not open for further replies.

nread

Technical User
Oct 31, 2001
58
0
0
GB
I'm not much of a UNIX man but if i have 31 files which i need to mould into one file i need to use which command....?

Cheers in advance....
 
Use

cat file1 file2 ...

or

cat file*

Hope this helps CaKiwi
 
Thats spot on, thanx.......
 
Errmm - I should point out here that one of the examples that CaKiwi gives is a bit risky (sorry CaKiwy)

this one: cat file*

This is what that command will do. In, say, a directory with four files named:

file1, file2, file3 and file4

the command line: 'cat file*' gets expanded to:

cat file1 file2 file3 file4

This takes the contents of file1, file2 and file3 and puts it into a file named file4 - so it overwrites an existing file. If that's what you want to do then fine - it usually isn't though.

This is a favorite mistake of DOS people learning UNIX (I made it, for instance - a "couple" of years ago (and more than once as well... ahem)) and it comes from the difference between the ways UNIX and DOS based systems interpret wild cards.

Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Well spotted Mike. It was a little early in the morning here in California when I posted that. CaKiwi
 
<grin> Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
No wait, Mike, I think you are wrong. cat file* will send the 4 files to standard output. cat file* > file4 would be needed to overwrite file4.
CaKiwi
 
doh!!!!!

yep - you're right...... Sorry CaKiwi..... <hits head on desk> Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
I was thinking of 'mv file*' which *does* have an interesting side effect.... Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top