Lauri's notes

Linux command line tools

uniq

sort a b | uniq             # union - items in either a or b
sort a b | uniq -d          # intersection - items both in a and b
sort a a b | uniq -u        # difference - items in b not in a
sort a b | uniq -u          # symmetric difference - items in only one file

cat a b | sort -u           # a union b
cat a b | sort | uniq -d    # a intersect b
cat a b b | sort | uniq -u  # difference a – b
cat a b | sort | uniq -u    # symmetric difference

join -t'\0' -a1 -a2 a b     # union of sorted files
join -t'\0' a b             # intersection of sorted files
join -t'\0' -v2 a b         # difference of sorted files
join -t'\0' -v1 -v2 a b     # symmetric difference of sorted files

date

date --date='25 Dec' +%A    # what day does xmas fall on, this year
date --date='@2147483647'   # convert seconds since the epoch to date

Perform some tasks when a file is changed

while date; do time node x.js; inotifywait -e close_write x.js; printf '\n\n'; done

Tags: shell, uniq, date

Have an update or suggestion for this note? You can edit it and send me a pull request.

Since 2009 to 2024