In this article let’s discuss about Bash return unique lines starting at nth field. Let’s go through the following methods without any delay.
# Basic syntax: uniq -f number input_file # Where number specifies the number of fields/columns to ignore from left # to right when doing comparisons to return unique lines # Note, uniq requires a sorted input. You can sort a file based on # specific fields with sort -k start_field_#,end_field_# # Example usage: sort -k 5,7 input_file | uniq -f 5 # This would sort the file using # fields 5-7 and then return unique lines based on a comparison # starting at the 5th field
Hope the above solution works.
Realted Posts : Sed delete line match