I have sorted data like this:
a
a f
b
c
c e
d
f z
Essentially these lines are each lists of aliases for the same thing, and they need to be merged. This is simplified. In case it matters in the real case I am handling filepaths that have moved and need to know what filepaths are essentially the same. The input has 1 column for the initial file and 2 columns when a file was renamed. Looking for an output like this:
a f z
b
c e
d
This is for a bash script on a typical Linux system, so any mostly standard tool will do. I have tried a few awk scripts from other questions dealing with this subject thus far and have not found good results.