简体   繁体   English

如何将egrep打印结果分成多列并导出到CSV文件

[英]How to split egrep print result in to multiple columns and export to a CSV file

I am trying to find all hardcoded strings in my xcode project and export the results to a csv file. 我试图在我的xcode项目中找到所有硬编码的字符串,并将结果导出到csv文件。 the below script that i used is giving me all the list of values along with filename as one string (ie /path/classA.m @"Value") and when i export same results to csv file obviously everything is copied in to one column. 我使用的以下脚本为我提供了所有值列表以及文件名作为一个字符串(即/path/classA.m @“ Value”),当我将相同结果导出到csv文件时,显然所有内容都复制到了一个列中。

find "${SRCROOT}" \( -name "*.h" -or -name "*.m" \) -print0 | xargs -0 egrep --with-filename --only-matching "($KEYWORDS).*\$" > myFile.csv

But i am trying to export the results in to csv so that i want to see filename under column and hardocded values in other column. 但是我试图将结果导出到csv中,以便我想查看列下的文件名和其他列中的hardocded值。

I am newbie in to scripting world. 我是脚本世界的新手。 Please help me to get over this 请帮我克服这个

find "${SRCROOT}" \( -name "*.h" -or -name "*.m" \) -print0 | xargs -0 egrep --with-filename --only-matching "($KEYWORDS).*\$" | sed 's/:/,/' > myFile.csv

Csv represents comma separated values CSV代表以逗号分隔的值

Search and replace first occurrence of : with , as file and value are separated by : in your case. 搜索并用替换第一次出现的:,因为文件和值之间用:分隔。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM