![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Grep Different Files Using a Loop? | foleyml | Shell Programming and Scripting | 6 | 01-02-2009 01:41 AM |
| grep and loop files | kashik | Shell Programming and Scripting | 4 | 06-16-2008 08:41 AM |
| Grep commands in loop | karthikn7974 | Shell Programming and Scripting | 0 | 04-28-2008 09:16 AM |
| grep -v while loop | bobo | UNIX for Dummies Questions & Answers | 8 | 01-26-2007 10:53 PM |
| grep in a loop | gundu | Shell Programming and Scripting | 7 | 03-28-2005 04:59 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
I am trying to work on a script file for tcsh but am fairly new to linux and have several questions.
1. What is the most effective way to set up a type of for loop? I need to run two loops that will each run in steps from a starting value to final value, eg i=0, 1==10, i++ in any other language. What is the most efficient way to set this up? So far we came up with: set i_forloopval = `echo "forloop" | awk '{for(p=0.7;p<1.43;p=p+0.08){print p}}'` set j_forloopval = `echo "forloop" | awk '{for(p=0.9;p<1.81;p=p+0.1){print p}}'` foreach i ($i_forloopval) foreach j ($j_forloopval) but it seems like there must be a more efficient way to go about this. 2. Every time it runs through the loop, it is going to run a program that creates a unique output file. Instead of having to manually search through this file, I was hoping to use grep to search for the line that we need. A given output might look like: 1\1\GINC-NODE006\Freq\RB3LYP\6-311G(d)\Br2\TYLERT\02-Feb-2009\0\\#N Ge om=AllCheck Guess=Read SCRF=Check GenChk RB3LYP/6-311G(d) Freq\\Title\ \0,1\Br,0.,0.,-0.0263112705\Br,0.,0.,2.3073112705\\Version=AM64L-G03Re vD.01\State=1-SGG\HF=-5148.2839416\RMSD=5.854e-11\RMSF=1.293e-06\Therm al=0.0034749\Dipole=0.,0.,0.\DipoleDeriv=0.,0.,0.,0.,0.,0.,0.,0.,0.,0. ,0.,0.,0.,0.,0.,0.,0.,0.\Polar=17.7366557,0.,17.7366557,0.,0.,51.89093 66\PG=D*H [C*(Br1.Br1)]\NImag=0\\0.00021679,0.,0.00021679,0.,0.,0.1438 2273,-0.00021679,0.,0.,0.00021679,0.,-0.00021679,0.,0.,0.00021679,0.,0 .,-0.14382273,0.,0.,0.14382273\\0.,0.,0.00000224,0.,0.,-0.00000224\\\@ the only information that is needed out of this is HF=-5148.2839416. What is the best way to extract only this from the output file? This is further complicated by the fact that this does not always occur on one line but will sometimes appear as: one one line: HF=-5148.28 39416 and then this part will be wrapped on to the next line. Any help would be appreciated. |
|
||||
|
Quote:
for the second question, please try this awk -F "\\" '{for(i=1;i<=NF;i++){if ($i ~ /HF/)print $i}}' file cheers, Devaraj Takhellambam |
| Sponsored Links | ||
|
|