File concatenation involves merging of one or multiple file contents into one single file. We all know that 'cat' linux command displays the contents of a file. Cat linux command can also be used to concatenate file contents into a single file. The concatenation command argument follows the following pattern as follows:
# cat inputfile1 inputfile2 ... inputfileN > outputfile
Here are more sample on how to merge and concatenate multiple file(s) of same file types into a single output file using cat.
# cat file1 file2 >> newfile
Legend
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
file1 and file2 - input files
">" - output operator for new output file
">>" - ouput operator for existing output file
newfile - output files
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*** Note that if newfile is already existing, it will be overwritten by the merged contents of all input files
More samples of merging contents of multiple files from terminal
The line below creates a new output file called newfile and all contents of new files are merged into the newfile using the redirection ">" operator.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# cat file1 file2 file3 file4 file5 file6 > newfile
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The line below merges all contents of all input files (file1,file2,file3,file4...file6) into an already existing 'existingfile' file using the redirection ">>" operator .
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# cat file1 file2 file3 file4 file5 file6 >> existingfile
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Take note that if the output file is already existing, the file access attributes and file ownerships of the output file is preserved. However, the date and time stamps would be changed and updated to current date/time values. This preservation state applies both to ">>" and ">" redirection operators.
Concatenation of files are usually being applied to readable file types, mostly to text date files in linux. Folder path can also be specified with input and output files when concatenating multiple files.
HTH
Categories
- HowTos (608)
- Linux Devices (39)
- Linux Diggs (620)
- Linux News (1541)
- Linux Videos (22)
Recent Posts
- IN DEPTH: Fedora 10 Preview
- Linus Torvalds on Linux Distributions
- AMD to Spin off Manufacturing Operations
- MySQL cofounder David Axmark leaving Sun
- Mono to contribute back to CLI; Microsoft says it would adopt in .NET
Blog Archive
-
▼
2008
(2302)
-
►
October
(140)
- Linus Torvalds on Linux Distributions
- AMD to Spin off Manufacturing Operations
- MySQL cofounder David Axmark leaving Sun
- Mono to contribute back to CLI; Microsoft says it ...
- Monitor your network with GroundWork Monitor Commu...
- The LXF Guide: Write a Perl module
- 8 Best First-person Shooter Games for Linux
- AppDeploy Community Launches Free Windows Installe...
- Ubuntu Tweak - Sneak Peak at Latest Version!
- POS stack targets Linux netbooks
- RIP LinuxWorld
- Firefox extension blocks dangerous Web attack
- Wikia co-founder to speak at linux.conf.au
- Wikia co-founder to speak at linux.conf.au
- Look Ma, No ‘X’
- Look Ma, No ‘X’
- Forget the damn Linux netbooks. Can Windows replac...
- Forget the damn Linux netbooks. Can Windows replac...
- Amarok 2.0 Beta 2 was released
- 6 Years As A Professional Software Developer
- Amarok 2.0 Beta 2 was released
- 6 Years As A Professional Software Developer
- Distribution Release: EnGarde Secure Linux 3.0.21
- Torvalds talks about his brand new blog
- Become a multimedia pro with the Vector Linux Mult...
- Linux Robot - Watch This Space
- Distribution Release: EnGarde Secure Linux 3.0.21
- Torvalds talks about his brand new blog
- Become a multimedia pro with the Vector Linux Mult...
- Linux Robot - Watch This Space
- Linux-Based E-Voting In Brazil
- Is .NET on Linux Finally Ready?
- Linux-Based E-Voting In Brazil
- Multi-core networking stack ported to PowerPC
- Google rev's photo editor for Linux
- Project releases version 2.0 of open source .Net
- One more 2.6.27 prepatch
- Stallman vs. Clouds
- How to Create and Use a Password Reset Disk in Win...
- OpenOffice.org Grows Up
- 45+ Sources and Sets of Photoshop Custom Shapes
- Clean up your filesystems with fslint
- NPX-9000 UMPC is inexpensive but underpowered
- Will Chrome Find a Home With SaaS?
- Setting Up Your New Computer - Beginner User
- Distribution Release: ALT Linux 4.1 "Desktop&...
- Ubuntu, Fedora, OpenSUSE beta-fest
- Ubuntu, Fedora, OpenSUSE beta-fest
- Italian carrier ships Linux MID
-
►
October
(140)
Wednesday, November 21, 2007
Concatenate Multiple Files in Linux
Subscribe to:
Post Comments (Atom)
ILoveTux - howtos and news | About | Contact | TOS | Policy


0 comments:
Post a Comment