如何使用 shell 命令从行中提取特定字段?

如何使用 shell 命令从行中提取特定字段?

文件1:

27/07/2014 10.10.03 Breaker1 was closed by Mr. A.Basu Spectrum ui6dms
29/07/2014 04.50.53 Breaker1 was opened by Mr. D.Gupta Spectrum ui6dms and one note added
30/08/2014 03.20.01 EarthSwitch was closed by Mr. K.Saha Spectrum ui1dms
01/09/2014 08.10.39 EarthIsolator was closed by Mr. R.Das Spectrum ui3dms

文件2:

27/07/2014 Breaker1 was closed by Mr. A.Basu ui6dms
29/07/2014 Breaker1 was opened by Mr. D.Gupta ui6dms
30/08/2014 EarthSwitch was closed by Mr. K.Saha ui1dms
01/09/2014 EarthIsolator was closed by Mr. R.Das ui3dms

我在 file1 中有超过 100 行,我希望输出为 file2。

答案1

以下命令产生请求的输出:

cut -d ' ' -f 1,3-10 file1

相关内容