# -- Q2 --
# Write a pipeline that finds the number of words in the book that have been used only once.
# Your pipeline should be case insensitive
echo "-- Q2 --"
onlyOnce=$(cat *txt | tr '[:upper:]' '[:lower:]' | tr -s '[:punct:][:space:]' ' '| tr ' ' '\n' | sort | uniq -ic | awk '$1 == 1 {print $2}')
echo "Words used only once:"
echo "$onlyOnce"
答え1
そしてawk
:
cat *txt |
tr '[:upper:]' '[:lower:]' |
tr -s '[:punct:][:space:]' |
awk '{a[$1]++}END{for (i in a) if (a[i] == 1) {print i}}'
あなたの場合はできません
cat files | ... | awk '{}' file
^^^^^ ^^^^
ファイルは一度だけ指定できます。