In this tutorial we will learn
how to merge to files in linux
How to sort the content of file
How to remove duplicate lines from a file.
How to merge two files in linux ?
There are two ways to to merge to files in linux .
Suppose we have files aayush1.txt and aayush2.txt .
In aayush1.txt the content is
In aayush2.txt the content is
To merge these two files we use the command :
Now applying the above command to our aayush1.txt and aayush2.txt
Now after merging files and writing content into aayush3.txt.
Lets see aayush3.txt
Same work can be done with this command :
In Linux, the operator ` |` is called a pipe.
How to sort the content of merged file alphabetically ?
Lets say we have file sorting.txt.
The content of sort is :
We want to sort the content of this file.
Command used to sort the content of this file is :
Now to merge the file with content in sorted form , we use the command :
How to remove duplicate content from file ?
Suppose we have a file duplicate.txt.
The content of duplicate is :
The command is :
Applying this command ,
Now we get ,
Finally now to get the merged file with sorted and unique content we will use the command :
Applying this command , you will get sorted and unique content from two files.
Comments
Post a Comment