我想只显示唯一的单词作为输出。如何定义grep表达式?
strings file.txt |grep (filter to display only whole words) | unique
答案 0 :(得分:0)
cat file.txt | sed -e 's/\s\+/\n/g' | sort -u
答案 1 :(得分:0)
听起来你需要翻译"空白"进入换行:
strings file.txt | tr '[:blank:]' '\n' | sort -u
答案 2 :(得分:0)
这应该有效:
s="sample word sample word samples"
echo "$s" |grep -oE "\b\w+\b"|sort -u
输出:
sample
samples
word