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*

8
  • This is great. I just was also wondering if there is anyway that I can make this script accept an argument for the filename so that I can batch process directories of simulation files? Commented Sep 22, 2013 at 8:49
  • Easily. Change NR==1 to FNR==1, which is the first record of the current file. Change exit to started=0 so the rest of the current file is ignored until the next file starts. Then invoke it with awk '...' *.out -- you can save the awk body in a file and use awk -f program.awk *.out. Are there more than one "Final structure" blocks in the file? Commented Sep 22, 2013 at 16:17
  • Nope, only 1 final lock per file, but would the way you describe write each input file to a respective cm file or aggregate them into one file. Commented Sep 23, 2013 at 5:10
  • I may have been a little unclear, I wanted to write each of the target data to their own file, named based off of the input file. The thing I'm confused about is that at the very end you have abc.out as the name, and I've tried tinkering around with it in a lot of ways and I still haven't been able to get the files to write based off of the input FILENAME. Commented Oct 1, 2013 at 0:25
  • I do that in the NR==1 section. First f is a copy of the current filename, then I substitute the extension ".out" replacing with ".cm". So it does work for each file. Commented Oct 1, 2013 at 0:34