1

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
  • 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 ?

2 Answers 2

8
 awk '{print $0 > "file_"$1"_"$2}' file
Sign up to request clarification or add additional context in comments.

2 Comments

Or possibly ...print $3 > ... if only you only want the values and not the full line.
yes, if OP only wants the values. I will leave it as $0 for the sake of generality.
0

Pure Bash:

rm --force file_*

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.