c****j 发帖数: 258 | 1 someone asked me to explain this awk usage, it looks like an interesting
question, and potentially useful for some rare case, so I post it here.
echo -e "aa\nbb\ncc\naa\ncc" | awk \!'x[$0]++'
enjoy! | c****j 发帖数: 258 | 2 this is used to remove duplicate lines, I think the one who wrote this is
just trying to confuse his readers, it can be written as
awk '!x[$0]'
it's better than sort/uniq coz it preserve the original order. you can
remove the ! to check what is duplicated. |
|