- Linux Admin Tutorial
- Home
- CentOS Overview
- Basic CentOS Linux Commands
- File / Folder Management
- User Management
- Quota Management
- Systemd Services Start and Stop
- Resource Mgmt with systemctl
- Resource Mgmt with crgoups
- Process Management
- Firewall Setup
- Configure PHP in CentOS Linux
- Set Up Python with CentOS Linux
- Configure Ruby on CentOS Linux
- Set Up Perl for CentOS Linux
- Install and Configure Open LDAP
- Create SSL Certificates
- Install Apache Web Server CentOS 7
- MySQL Setup On CentOS 7
- Set Up Postfix MTA and IMAP/POP3
- Install Anonymous FTP
- Remote Management
- Traffic Monitoring in CentOS
- Log Management
- Backup and Recovery
- System Updates
- Shell Scripting
- Package Management
- Volume Management
- Linux Admin Useful Resources
- Linux Admin - Quick Guide
- Linux Admin - Useful Resources
- Linux Admin - Discussion
Linux Admin - paste Command
The paste command is used to merge lines of files. Following are the commonly used switches.
Switch | Action |
---|---|
-d | Specify delimiter |
-s | Paste one file at a time instead of in parallel |
The best example to clearly understand the -s switch is see it −
[root@centosLocal Documents]# cat myOS.txt && cat lines.txt Linux Windows Solaris OS X BSD line 1 line 2 line 3 line 4 line 5 [root@centosLocal Documents]# past myOS.txt lines.txt [root@centosLocal Documents]# paste myOS.txt lines.txt Linux line 1 Windows line 2 Solaris line 3 OS X line 4 BSD line 5 [root@centosLocal Documents]# paste -s myOS.txt lines.txt Linux Windows Solaris OS X BSD line 1 line 2 line 3 line 4 line 5 [root@centosLocal Documents]#
So, if we wanted a ":" colon or Tab separated file by combining two different files, the paste command makes this fairly simple −
[root@centosLocal Documents]# paste -d":" myOS.txt lines.txt Linux:line 1 Windows:line 2 Solaris:line 3 OS X:line 4 BSD:line 5 [root@centosLocal Documents]# paste -d"\\t" myOS.txt lines.txt Linux line 1 Windows line 2 Solaris line 3 OS X line 4 BSD line 5 [root@centosLocal Documents]#
With paste it's pretty easy to take a file, and make it into Tab separated columns −
[root@centosLocal Documents]# paste -d"\t" - - < lines.txt line 1 line 2 line 3 line 4 line 5 [root@centosLocal Documents]#
basic_centos_linux_commands.htm
Advertisements
To Continue Learning Please Login
Login with Google