Based on other answer you can use sort command but you can explicitly mention output file and do the sort in place (w/o intermediate file)
sort -u -o new.txt old.txt new.txt One of possible awk ways:
awk -i inplace '{z[$0]=1} END{for( i in z) print i}' new.txt old.txt Be warned that this can "eat" a lot of memory if one or both input files are long. inplace will keep the output in new.txt