我已经编写了一个命令,可以将文件中的所有单词打印在不同的行上:
sed -e 's/[^a-zA-Z]/\n/g' test_input | grep -v "^$"
如果test_input包含"My bike is fast and clean",那么这个命令的输出将是: My bike is fast and clean
现在我需要另一种版本的命令,可以打印文本中所有的两个单词的组合,像这样(仍然使用Bash): My bike bike is is fast fast and and clean
您知道如何实现吗?
如果test_input包含"My bike is fast and clean",那么这个命令的输出将是: My bike is fast and clean
现在我需要另一种版本的命令,可以打印文本中所有的两个单词的组合,像这样(仍然使用Bash): My bike bike is is fast fast and and clean
您知道如何实现吗?
sed -r ...
,并将$1
更改为\1
,它会每行打印两个单词,但不会重复这些单词。 - Dennis Williamson