#!/bin/bash icd10_who="./WHO ICD-10 (2019)/icd10-2019_categories_only.psv" icd10cm_cms="./icd10cm_codes_addenda_2019/icd10cm_codes_2019.psv" #concatenate the two files #then lexically sort them by first column and then second column(reversed) #then sort/unique based on first column #then save to file cat "$icd10_who" "$icd10cm_cms" | sort -t "|" -k 1,1 -k 3,3r | sort -u -t "|" -k 1,1 > icd10_combined-who-cms.psv