0

I have these files;

*_NOMm6xR.res
*_NOMm5xR.res
*_NOMm4xR.res
*_NOMm3xR.res
*_NOMm2xR.res
 *35LS05*.res 
*_NOMm1xR.res
*_NOM_SRP.res
 *35LE50*.res 
*_NOMp1xR.res
*_NOMp2xR.res
*_NOMp3xR.res
*_NOMp4xR.res
*_NOMp5xR.res
*_NOMp6xR.res
*_NOMp7xR.res
*_NOM_C2P.res

content of above files;

dynAB 1193.95, Intrusion2mal -0.16, TIME 0.00400002, Value MAX 1194.11, Value MIN 1194.03

I want result file dynAB.txt with following format;

           Value MAX   Value MIN   TIME         dynAB
_NOMm6xR : 1194.11,    1194.03,    0.00400002,  1193.95,
_NOMm5xR :
_NOMm4xR :
_NOMm3xR :
_NOMm2xR :
  35LS05 :
_NOMm1xR :
_NOM_SRP :
  35LE50 :
_NOMp1xR :
_NOMp2xR :
_NOMp3xR :
_NOMp4xR :
_NOMp5xR :
_NOMp6xR :
_NOMp7xR :
_NOM_C2P :
  • 1
    do u literally have those asterisk in the filename? – msp9011 Apr 16 at 14:00
  • 1
    no... due to confidentiality i can not mention entire file name. i use ll -tr or ls in linux – Nayak Apr 16 at 14:01
  • and i need same sequence (shown file listing) – Nayak Apr 16 at 14:02
  • What have you tried so far? We can't comment on your code without seeing it. Suggestion -- you need a perl script, not grep. – hymie Apr 16 at 14:08
  • grep -i "intru" *_NOMm6xR.res | cut -d "," -f1 | sort > res1.txt but this does not print file name in the begining.. – Nayak Apr 16 at 14:11
0

Not the exact output, but close:

awk '
    BEGIN{ OFS="\t"; print "Filename","Value_MAX","Value_MIN","TIME","dynAB" }
    FNR == 1 { OFS="\t"; print FILENAME,$9,$12,$6,$2 }
' *.res

Output:

Filename      Value_MAX  Value_MIN  TIME         dynAB
_NOMm6xR.res  1194.11,   1194.03    0.00400002,  1193.95,
  • I have tested; awk 'BEGIN{ OFS="\t"; print "Simulation","Value_MAX","Value_MIN","TIME","dynAB" } FNR == 1 { OFS="\t"; print Simulation,$9,$12,$6*1000,$2 } ' *.res > test.txt and output is; Simulation Value_MAX Value_MIN TIME dynAB 1194.11, 1194.03 4.00007 1193.95, Is it possible to refine it further since filename is missing and the columns are not properly oriented under relevent headers. Note: I have added '*1000' to have rounded values. – Nayak Apr 18 at 13:58
  • FILENAME is a pre-defined variable in awk, use that in your second print statement instead of Simulation. – pLumo Apr 18 at 14:02

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.