shell delete the same line or duplicate lines in the file

 shell delete the same line or duplicate lines in the file

1. sort + uniq
sort -k2n file | uniq > a.out

2. sort + awk
sort -k2n file | awk '{if ($0!=line) print;line=$0}'
or
sort file | awk -F- '!i[$1]++'

3. sort + sed
sort -k2n file | sed '$!N; /^\(.*\)\n\1$/!P; D'

4. sed
sed -n 'n;p'

5. awk
cat file | awk '!i[$1]++'

Comments

Popular posts from this blog

Python Receiving and parse JSON Data via UDP protocol

ubus lua client method and event registration code demo/example