I have an input file like below. file.txt14 2.692022 author1 014 2.57826 author2 1229 2 author3 2323 2 author4 3514 2.0625 author5 4I am trying to split the file with the duplicated values as one file and the rest of values as another file. So, for the above input, I am trying to generate files like,file1.txt14 2.692022 author1 014 2.57826 author2 1file2.txt229 2 author3 2323 2 author4 3514 2.0625 author5 4I am not able to figure out how to use awk for this purpose. awk '{print $1}' file.txt | uniq -d > file1.txtThe above command gives me only the duplicated values in a file. Also, it gives me only the field1 but not all the 3 fields. 
awk to split the input file into 2 files(one for duplicated values and one for unique values)
awk;perl;gawk
awk supports direct file redirection in its syntax.awk 'BEGIN{prev=} {if($1==prev) { print $0 > duplicates.txt} else { print $0 > originals.txt}; prev=$1; }' file.txtI assumed the file is already sorted. If it's not, it gets much harder.EDIT: is this better?awk 'BEGIN{prev=; prevfull=}$1==prev{ if(prevfull!=){print prevfull > duplicates.txt; prevfull=}; print > duplicates.txt}$1!=prev{ if(prevfull!=){print prevfull > originals.txt}; prevfull=$0}{prev=$1; } END{print prevfull}' file.txtIt can definitely be done better (the ifs are definitely not optimal) but it shows the general idea.