Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • What problem? How does this fail? It is needlessly complcated for what I think you need, but since you don't tell us how it fails, or show us anything about the directories and files you need to process it is hard to know. Can you please edit your question and i) show us the directory structure and ii) some example files, iii) tell us how this failed and, most importantly, iv) show us the output you expect. Commented Jun 5, 2022 at 17:13
  • For instance, your script is only keeping the last value from the last file. Is that what you want or do you want the last value from each file? Commented Jun 5, 2022 at 17:14
  • I have tried to elaborate on what I need. your code is very good but it saves the values in different .txt files. I need only one .txt file in the parent folder. Thank you so much for your attention. Commented Jun 5, 2022 at 17:41
  • Oh. OK, your code did the same thing, that's why I did it that way. Do you also need that last occurrence of scf done in each file? Can there be more than one or do all your files just have one scf done? Commented Jun 5, 2022 at 20:43
  • Thank you for answering. I prepared the following code: #!/bin/bash for dir in /; do grep -i 'scf done' "$dir"/.log | awk 'END{print ""$5}'| column -t -s ":" > "${dir///}".tmp done for file_name in .tmp do echo "${file_name%%.} : " cat "$file_name" done > tmp awk 'NR%2{printf "%s ",$0;next;}1' tmp > tmp2 sort -k 3 tmp2 > Energy.txt rm *.tmp tmp tmp2 cat Energy.txt It does work! But rather stupid. Can we convert it to a more efficient script using advanced commands? Commented Jun 5, 2022 at 20:53