开发者

help with selecting rows using awk

开发者 https://www.devze.com 2022-12-12 16:55 出处:网络
I have a file as follows 2.54 Ghzval 2.53 Ghzval1 1.6 Ghzval2 800 Mhzval3 2.54 Ghzval4开发者_如何学JAVA

I have a file as follows

  • 2.54 Ghz val
  • 2.53 Ghz val1
  • 1.6 Ghz val2
  • 800 Mhz val3
  • 2.54 Ghz val4
  • 开发者_如何学JAVA
  • 2.53 Ghz val5
  • 1.6 Ghz val6
  • 800 Mhz val7

and the pattern continues ... I want to extract all 2.54 Ghz values in one file1 and all 2.53 Ghz values in another file2 , 1.60 Ghz values in file3 and 800 Mhz values in file4

can anyone help me with this ?


 awk '{print $0 > "file_"$1"_"$2}' file


Pure Bash:

rm --force file_*

while read speed magnitude value; do
    echo -e "${value}" >> "file_${speed}_${magnitude}"
done < file
0

精彩评论

暂无评论...
验证码 换一张
取 消