Hundreds of files need manual preparation. Does shell script could do it automatically?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Hundreds of files need manual preparation. Does shell script could do it automatically?
# 8  
Old 06-01-2015
You always supersizing me with super intelligent and SUPER SMART script! Many Thanks! !! This output fully matches the format of the required input!
You are really a genius!

---------- Post updated at 04:39 AM ---------- Previous update was at 03:56 AM ----------

Quote:
Originally Posted by RudiC

DON'T! That kills the logics.
Now, I understand what does the logic mean! it's efficiency!
Split awk make the script much less efficient!

The time with a single AWK operation,
Code:
real    0m0.010s
user    0m0.008s
sys     0m0.000s

The time with splitting AWK operation,
Code:
real    0m0.021s
user    0m0.016s
sys     0m0.004s

Two times fast! That always a SMART code mean!
# 9  
Old 06-01-2015
No, it's NOT efficiency. When you quit awk, all parsed values so far are lost and can't be utilized any more. The data evaluation is done step by step which build on each other.

On the other hand, your observation reg. timing is true, but a large part of it is opening and reading files and creating processes.

---------- Post updated at 22:52 ---------- Previous update was at 22:49 ----------

Hmmm - looking into it again, with the pure printing approach, three awk processes might do the work. What did you mean with "other two parts dead with unexpected outputs."?

Last edited by RudiC; 06-01-2015 at 06:09 PM..
# 10  
Old 06-01-2015
Code:
awk 'FNR==1             {gsub (/^.*\/|\..*$/, "", FILENAME)
                         print "Title of the job"
                         print FILENAME
                         print "Important Comment: The number of lines in the input file, and the"
                         print "*exact* typography for text input needs to be *rigorously* followed!!"
                         print "Temperatures (Next two lines: \"List\", or \"Interval\", then no of temps.)"
                         print "  List"
                         print "  1"
                         print "Values (If \"Interval\", give start and finish temp.)"
                         print "  298.15"
                         print "Pressure (in atm or bar - if given in atm, enter as a negative number. -1 is the G09 default)"
                         print " -1."
                         print "Calculated properties of the species (e.g. from Gaussian output)"
                         print "Electronic Energy"
                        }' feco4_s.log

awk '/SCF Done:/        {foundstring=$5} END{print foundstring}' feco4_s.log

awk 'FNR==1             {print "Nature of species (Atom = 0, Linear = 1, or General = 3)"
                         print "  3"
                        }
/Rotational.*ber/       {print "Rotational factor (symmetry factor)"
                         print "  "$NF
                         print "Electronic degeneracy (multiplicity)"
                        }' feco4_s.log

awk '/Multiplicity/     {foundstring=$6} END{print "  "foundstring"."}' feco4_s.log

awk 'FNR==1
/Molecular mass/        {print "Molecular Weight (amu)"
                         print $(NF-1)
                        }
/Frequencies/           {FC++;for (i=3; i<=5; i++) FR[FC,i]=$i}
/Eigenvalues -- /       {gsub (/\.[0-9][0-9][0-9][0-9][0-9]/,"& ")
                         printf "Moments of Inertia (in amu x au2; none for Atom, 1 for Linear, 3 for General)\n%s\n%s\n%s\n",
                                $3, $4, $5
                        }
END                     {print "Vibrational Frequencies (first line: number; then freqs. in cm-1)"
                         print 3 * FC
                         for (i=3; i<=5; i++) for (j=1; j<=FC; j++) print FR[j,i]
                        }
' feco4_s.log

On the basis of your first merged script, I broke a single AWK operation into multiples in order to obtain the last match of the pattern. However, I didn't understand why do we need "FNR==1" following AWK and the script run with multiple loops and printed a lot of duplicated text. When I PUT the FNR==1 to the last AWK, it works, but needs more operation time.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need to add code to hundreds of .html files

Need assistance to add code to hundreds of .html Code will look like below and needs to be added below <html> tag: <script> Some .js code here </script> This will be used in Fedora release 7 (Moonshine). I will appreciate any type of help and/or orientation. Thank you! (4 Replies)
Discussion started by: Ferocci
4 Replies

2. Shell Programming and Scripting

Best way to connect to hundreds of nodes and grep log files

Hi, What will be the best way to connect (ssh) to hundreds of nodes and grep log files parallely from shell. Using for loop seems to be sequential. Are there any shell built in construct which could be used to achieve this? Is the sub shell any good here? (1 Reply)
Discussion started by: agent001
1 Replies

3. Solaris

Renaming hundreds of files at the same time

Hi, I am having issues trying to figure out how to rename files like this: TEST1_B.tt To SQP_CAN_B.tt I have hundreds of files like those, I need to rename them automatically. Any help will be greatly appreciated. Thanks, (5 Replies)
Discussion started by: ocramas
5 Replies

4. Shell Programming and Scripting

Shell script to automatically download files

I am new to shell scripting and need to write a program to copy files that are posted as links on a specific url. I want all the links copied with the same file name and the one posted on the webpage containing the url onto a specific directory. That is the first part. The second part of the script... (2 Replies)
Discussion started by: libertyforall
2 Replies

5. Shell Programming and Scripting

automatically format Shell Script (bash)

Hi In TOAD I can write SQL code, then select the SQL code -> Menu Edit -> Format Code The output is well formatted code (correct indent, ...) Is there a tool (for Windows and/or UNIX) what can do the same for bash code? TOAD (software) - Wikipedia, the free encyclopedia (1 Reply)
Discussion started by: slashdotweenie
1 Replies

6. Shell Programming and Scripting

Shell script to invoke options automatically

i have a script which has 2 options. a b And a has 6 sub options. i want to write a script which will call the parent script and give options automatically. examle: linasplg11:/opt/ss/kk/01.00/bin # startup.sh /opt/ss/rdm/01.00 Please select the component to... (2 Replies)
Discussion started by: Aditya.Gurgaon
2 Replies

7. Shell Programming and Scripting

how to run shell script automatically

hi , i m trying to run bash scrip automaticially but i dont know how i can do this an anybody tell me how i can autorun shell script when i logon . thanks (9 Replies)
Discussion started by: tahir23
9 Replies

8. Shell Programming and Scripting

Script to automatically check ports in shell?

Good day, I'm new to linux environment...Is there any scripts available for me to check ports (lets say port 80 and 21) through shell with just a single commandline? Any response is very much appreciated.. thanks (4 Replies)
Discussion started by: arsonist
4 Replies
Login or Register to Ask a Question