I am reading values of different variables from a SLHA file and putting value of each variable in a dedicated file using shell script. I have around 50 such variables so 50 data files are generated. A portion of the code is given below-

 grep "        25" SPheno.spc|head -1|awk {'print $2'} >> mh.out
 grep "   1000001" SPheno.spc|head -1|awk {'print $2'} >> mdl.out
 grep "   2000001" SPheno.spc|head -1|awk {'print $2'} >> mdr.out
 grep "   1000002" SPheno.spc|head -1|awk {'print $2'} >> mul.out
 grep "   2000002" SPheno.spc|head -1|awk {'print $2'} >> mur.out

I want to merge all of these .out files from the shell itself in a single grand file such that there are separate columns for each variable in the combined file. I tried to use c++ but opeing such large number of files does not appear efficient.

  • You call grep, head and awk 50 times each instead of calling awk once? And you are worried about efficiency...? – Hauke Laging Aug 22 '17 at 18:11
cat m*.out >combined_file.out
  • I want separate columns for each variable in the combined file. This command will just put everything in a single column. – solphy101 Aug 22 '17 at 18:17
  • @solphy101 And would you claim that a reasonable reader can take this from your question? – Hauke Laging Aug 22 '17 at 18:18
  • Let me edit the question. – solphy101 Aug 22 '17 at 18:20
paste m*.out > combined_file

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.