given file1
a b c d e f h n o p q j k l m and file2
3 1 0 1 2 i sort file1 in order given in file2. output should be:
n o p q e f h j k l m b c d basically, how can add file2 in front of file1 prefix column, , sort column, remove prefix column?
the answer here close match, doesn't answer question.
paste friend:
paste f2 f1 | sort | cut -d$'\t' -f2- in steps:
$ paste f2 f1 # join files 3 b c d 1 e f h 0 n o p q 1 j k 2 l m $ paste f2 f1 | sort # sort them 0 n o p q 1 e f h 1 j k 2 l m 3 b c d $ paste f2 f1 | sort | cut -d$'\t' -f2- # remove 1st column n o p q e f h j k l m b c d
Comments
Post a Comment