- Kali Linux Tutorial
- Kali Linux - Home
- Installation & Configuration
- Information Gathering Tools
- Vulnerability Analyses Tools
- Kali Linux - Wireless Attacks
- Website Penetration Testing
- Kali Linux - Exploitation Tools
- Kali Linux - Forensics Tools
- Kali Linux - Social Engineering
- Kali Linux - Stressing Tools
- Kali Linux - Sniffing & Spoofing
- Kali Linux - Password Cracking Tools
- Kali Linux - Maintaining Access
- Kali Linux - Reverse Engineering
- Kali Linux - Reporting Tools
- Kali Linux Useful Resources
- Kali Linux - Quick Guide
- Kali Linux - Useful Resources
- Kali Linux - Discussion
How to merge lines of files in the Linux system?
To merge lines of files, we use the paste command in the Linux system.
The paste command is used to combine files horizontally by outputting lines consisting of the sequentially corresponding lines from each FILE, separated by TABs to the standard output. When it has completed its operating for the last file, paste will output newline character and move on to the next line.
The general syntax of the paste command is as follows −
paste [OPTION]... [FILE]...
Note – with no FILE the paste command read input from standard input.
Brief description of options available in the paste command.
|Sr.No.||Option & Description|
Reuse characters from LIST instead of TABs
Paste one file at a time instead of in parallel
Line delimiter is NULL, not newline
Displays a help message and then exits.
It gives info about the version and then exits.
To merge the files parallelly, we use the paste command as shown below.
First, we need to create two files to merge simultaneously.
$ cat >text1.txt EMP_ID EMP_NAME 001 GAURAV 002 SID $ cat >text2.txt EMP_AGE 22 23 $ paste text1.txt text2.txt EMP_ID EMP_NAME EMP_AGE 001 GAURAV 22 002 SID 23
Here, we will use the above files and save output in another file instead of standard output using the paste command in the Linux system as shown below.
$ paste text1.txt text2.txt >text.txt
To merge the files parallelly with delimiter, we use the -d option with the paste command as shown below.
$ paste -d ‘|’ text1.txt text2.txt EMP_ID EMP_NAME |EMP_AGE 001 GAURAV |22 002 SID |23
To merges the files in a sequential manner, we use the -s option with the paste command as shown below.
$ paste -s text1.txt text2.txt
To check more information about the paste command, we use the --help option with the paste command in the Linux operating system as shown below.
$ paste --help
To check version information of the paste command, we use the --version option with the paste command in the Linux operating system as shown below.
$ paste --version
- Related Articles
- How to sort lines of text files in Linux?\n
- How to join lines of two files on a common field in Linux?
- How to remove sections from each line of files in the Linux system?\n
- How to compare two sorted files line by line in the Linux system?
- How to Merge PDF Files in Bash?
- How to remove files and directories in the Linux operating system using the terminal?\n
- How to Count Number of Files in Linux
- Python - How to Merge all excel files in a folder
- How to create links between files in the Linux?
- Linking to Files in Linux
- Java program to merge contents of all the files in a directory
- How to flushes file system buffers in the Linux operating system?
- How to retrieve a specific number of lines from files in PowerShell?
- How to Reverse Order of Lines in a File in Linux
- How to Randomize Lines in a File in Linux