I have two files (file1.txt & file2.txt ). The files are only examples.
How can I merge the two files, in order to create the file - merge_files.txt as example 3?
I am now writing a KornShell (ksh
) script, so merge can be done with KornShell, AWK, sed, a Perl one-liner, etc.
Background - why I need to merge the files: my target is to rename the old file (exist in first field) to a new file (exist in the second field).
Example 1
File file1.txt
/etc/port1-192.9.200.1-255.555.255.0
/etc/port2-192.9.200.1-255.555.255.0
/etc/port3-192.9.200.1-255.555.255.0
/etc/port4-192.9.200.1-255.555.255.0
/etc/port5-192.9.200.1-255.555.255.0
.
.
.
.
Example 2
File file2.txt
/etc/port1-192.90.2.1-255.555.0.0
/etc/port2-192.90.2.1-255.555.0.0
/etc/port3-192.90.2.1-255.555.0.0
/etc/port4-192.90.2.1-255.555.0.0
/etc/port5-192.90.2.1-255.555.0.0
.
.
.
.
Example 3
File merge_files.txt
/etc/port1-192.9.200.1-255.555.255.0 /etc/port1-192.90.2.1-255.555.0.0
/etc/port2-192.9.200.1-255.555.255.0 /etc/port2-192.90.2.1-255.555.0.0
/etc/port3-192.9.200.1-255.555.255.0 /etc/port3-192.90.2.1-255.555.0.0
/etc/port4-192.9.200.1-255.555.255.0 /etc/port4-192.90.2.1-255.555.0.0
/etc/port5-192.9.200.1-255.555.255.0 /etc/port5-192.90.2.1-255.555.0.0
.
.
.
.
.
Example 4 (merge_files.txt structure)
first field second field
OLD file NEW file
merge_files.txt
after renaming the files?)