shell - how to merge two files in unix -
i want merge 2 files in unix. how can this?
eg file1 contains:
host1:90:/users:user1 host2:90:/users:user1 host3:90:/users:user1 host4:90:/users:user1 host5:90:/users:user1 host6:90:/users:user1 host7:90:/users:user1
file2 contains:
host1:owner_name host2:owner_name host3:owner_name host4:owner_name host5:owner_name host6:owner_name host7:owner_name
output result:
host1:90:/users:user1:owner_name host2:90:/users:user1:owner_name host3:90:/users:user1:owner_name host4:90:/users:user1:owner_name host5:90:/users:user1:owner_name host6:90:/users:user1:owner_name host7:90:/users:user1:owner_name
i have used command paste -d ':' file1 file2 >merged_file
, getting:
host1:90:/users:user1:host1:owner_name host2:90:/users:user1:host2:owner_name host3:90:/users:user1:host3:owner_name host4:90:/users:user1:host4:owner_name host5:90:/users:user1:host5:owner_name host6:90:/users:user1:host6:owner_name host7:90:/users:user1:host7:owner_name
use join
instead:
% bring together -t':' file1 file2 host1:90:/users:user1:owner_name host2:90:/users:user1:owner_name host3:90:/users:user1:owner_name host4:90:/users:user1:owner_name host5:90:/users:user1:owner_name host6:90:/users:user1:owner_name host7:90:/users:user1:owner_name
shell unix
No comments:
Post a Comment