Shell-Script
如何使用 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。
以下命令產生請求的輸出:
cut -d ' ' -f 1,3-10 file1