【发布时间】:2013-03-09 04:08:53
【问题描述】:
我有一个包含大量数值 (+2M) 的文件“tbook1”。我必须在 bash (Solaris / RHEL) 中执行以下操作:
Do following:
Remove 1st and last 2 lines
Remove (,") & (")
Substitute (, ) with (,)
我可以使用两种方法:
Method1:
sed -e 1d -e 's/,"//g' -e 's/, /,/g' -e 's/"//g' -e 'N;$!P;$!D;$d' tbook1 > tbook1.3
method2:
tail -n +2 tbook1 | head -n -2 > tbook1.1
sed -e 's/,"//' -e 's/, //' tbook 1.1 > tbook1.2
我想知道哪个更好,即更快更高效(资源使用)?
【问题讨论】:
-
你能更新文件吗?
-
不..我不能就地做...我必须保持原来的'tbook'完好无损!