在unix中使用grep命令
我有一个文件,我想根据一个单词对它进行排序,并删除特殊字符。 grep命令用于搜索字符在unix中使用grep命令,unix,Unix,我有一个文件,我想根据一个单词对它进行排序,并删除特殊字符。 grep命令用于搜索字符 -b Display the block number at the beginning of each line. -c Display the number of matched lines. -h Display the matched lines, but do not display the filenames. -i Ignore case sensitivity. -l Display
-b Display the block number at the beginning of each line.
-c Display the number of matched lines.
-h Display the matched lines, but do not display the filenames.
-i Ignore case sensitivity.
-l Display the filenames, but do not display the matched lines.
-n Display the matched lines and their line numbers.
-s Silent mode.
-v Display all lines that do NOT match.
-w Match whole word
但是
如何使用grep命令执行
文件排序
和删除特殊字符
和数字。grep在所有文件中搜索以查找匹配的文本。它并没有真正排序,也并没有真正切碎和改变输出。您可能需要使用sort命令
sort <filename>
排序
以及发送到awk命令或sed命令的输出,这是处理文本的常用工具
sort <filename> | sed 's/REPLACE/NEW_TEXT/g'
sort | sed's/REPLACE/NEW_TEXT/g'
我可以想象上面的情形。grep在所有文件中搜索匹配的文本。它并没有真正排序,也并没有真正切碎和改变输出。您可能需要使用sort命令
sort <filename>
排序
以及发送到awk命令或sed命令的输出,这是处理文本的常用工具
sort <filename> | sed 's/REPLACE/NEW_TEXT/g'
sort | sed's/REPLACE/NEW_TEXT/g'
我可以想象上面的情况。下面的命令就可以做到这一点
sort FILE | tr -d 'LIST OF SPECIAL CHARS' > NEW_FILE
下面的命令将执行此操作
sort FILE | tr -d 'LIST OF SPECIAL CHARS' > NEW_FILE
我认为这是一个很难理解的问题,更不用说它几乎肯定与SO无关。sort命令将对其进行排序并将其传送到grep或sed,并使用regexpdefine删除您的字符定义
根据单词对其进行排序和特殊字符我认为这离一可理解的问题还有很长的路要走,更不用说它几乎肯定与SO无关。sort命令将对其进行排序,并将其传送到grep或sed,然后使用regexpdefine删除您的字符根据单词和特殊字符对其进行排序