我有一个文件是'|' 划定的。文件中的字段之一是时间戳。该字段采用以下格式:MM-dd-yyyy HH:mm:ss
我希望能够打印到文件中的唯一日期。我可以使用 cut 命令 ( cut -f1 -d'|' _file_name_ |sort|uniq
) 来提取唯一日期。但是,对于该领域的时间部分,我看到了数百个结果。运行 cut 命令后,我想使用前 11 个字符的子字符串来显示唯一日期。我尝试使用 awk 命令,例如:
awk ' { print substr($1,1-11) }' | cut -f1 -d'|' _file_name_ |sort|uniq > _output_file_
我没有运气。我会以错误的方式解决这个问题吗?有没有更简单的方法来提取我需要的数据。任何帮助,将不胜感激。