Sponsored Content
Full Discussion: for loop and grep question
Top Forums Shell Programming and Scripting for loop and grep question Post 302309781 by redalert013 on Wednesday 22nd of April 2009 10:30:45 PM
Old 04-22-2009
Error for loop and grep question

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.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

grep in a loop

Hi , I am trying a script which takes user input userid . I am stuck how to check whether that is a valid user id or not in the audit log files. My code is : cd $CCP_AUDIT cat * > /export/home/$USR/l***/files echo "UserId:\c" read UserId #Date Function echo "DATE : \c" read xxx I... (7 Replies)
Discussion started by: gundu
7 Replies

2. UNIX for Dummies Questions & Answers

grep -v while loop

alist contain: a b c d e blist contain: a b c the code: #!/usr/bin/ksh cat blist | while read line do grep -V "$line" alist > data done (8 Replies)
Discussion started by: bobo
8 Replies

3. Shell Programming and Scripting

Grep commands in loop

Hi All, Reference to my previous post I need to compare all the lines in the file1 with file2 for this condition if file1 {$3,$5} ==file2 {$3,$5} then grep file2{$1}latest date. need output in file3 10/04/2008 09/04/2008 09/04/2008 08/04/2008 can anyone suggest me Thanks... (0 Replies)
Discussion started by: karthikn7974
0 Replies

4. Shell Programming and Scripting

BASH loop inside a loop question

Hi all Sorry for the basic question, but i am writing a shell script to get around a slightly flaky binary that ships with one of our servers. This particular utility randomly generates the correct information and could work first time or may work on the 12th or 100th attempt etc !.... (4 Replies)
Discussion started by: rethink
4 Replies

5. Shell Programming and Scripting

Using grep within a while loop

Hi all, I have the below script to get input but i cannot get grep to work. input1.txt AAAAAAAAG input2.txt >gi|184009.1| LEAFY-like |AAAAAAAAGSGGGDHLPY However, when i use grep -f input1.txt input2.txt i cannot get any output matches (note that the match is underlined). Is it... (8 Replies)
Discussion started by: turkishvan
8 Replies

6. Shell Programming and Scripting

Help on grep in a do while loop

So this is what I'm trying to do: I have a file called registry.txt which has a list of registry entries I want to search for. I have another file called inctrl.txt on which I want to perform the search on. Here's the example contents of registry.txt SOFTWARE\Microsoft\Security... (3 Replies)
Discussion started by: r4v3n
3 Replies

7. Red Hat

using grep in a while loop

Hello everybody, I have been searching it, but it seems I am unable to find the correct information, that s why I am asking you guys, hoping somebody get an idea. Here is my problem : I want a script to loop until a string is identified in a log file. Here is the script : #!/bin/sh... (5 Replies)
Discussion started by: guyiom
5 Replies

8. Homework & Coursework Questions

GREP loop

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I need to search through the users home directories for keywords, display them. The code listed below will show... (7 Replies)
Discussion started by: jcllns1
7 Replies

9. Shell Programming and Scripting

Grep issue in for loop

Hi friends, I am trying to use a grep command in for loop but i keep getting an error message on the grep, here is the code grep -i "Target connection group" $LogName | awk '{print $10}' > TableNames.rpt cat TableNames.rpt | sort -u > DistinctTable.rpt ... (3 Replies)
Discussion started by: Aditya_001
3 Replies

10. Shell Programming and Scripting

Ps ax with grep in loop

Hello, I have built the following script to check if processes supplied by the argument are running or not. #!/bin/bash PROCLIST=$1 PROCESS="0" ERROR_PROCS="" IFS='+' read -ra ADDR <<< "$PROCLIST" for PROC in "${ADDR}"; do if ; then PROCESS=1 ... (9 Replies)
Discussion started by: nms
9 Replies
GLUBEGINTRIM(3G)														  GLUBEGINTRIM(3G)

NAME
gluBeginTrim, gluEndTrim - delimit a NURBS trimming loop definition C SPECIFICATION
void gluBeginTrim( GLUnurbs* nurb ) void gluEndTrim( GLUnurbs* nurb ) PARAMETERS
nurb Specifies the NURBS object (created with gluNewNurbsRenderer). DESCRIPTION
Use gluBeginTrim to mark the beginning of a trimming loop, and gluEndTrim to mark the end of a trimming loop. A trimming loop is a set of oriented curve segments (forming a closed curve) that define boundaries of a NURBS surface. You include these trimming loops in the defini- tion of a NURBS surface, between calls to gluBeginSurface and gluEndSurface. The definition for a NURBS surface can contain many trimming loops. For example, if you wrote a definition for a NURBS surface that resem- bled a rectangle with a hole punched out, the definition would contain two trimming loops. One loop would define the outer edge of the rec- tangle; the other would define the hole punched out of the rectangle. The definitions of each of these trimming loops would be bracketed by a gluBeginTrim/gluEndTrim pair. The definition of a single closed trimming loop can consist of multiple curve segments, each described as a piecewise linear curve (see gluPwlCurve) or as a single NURBS curve (see gluNurbsCurve), or as a combination of both in any order. The only library calls that can appear in a trimming loop definition (between the calls to gluBeginTrim and gluEndTrim) are gluPwlCurve and gluNurbsCurve. The area of the NURBS surface that is displayed is the region in the domain to the left of the trimming curve as the curve parameter increases. Thus, the retained region of the NURBS surface is inside a counterclockwise trimming loop and outside a clockwise trimming loop. For the rectangle mentioned earlier, the trimming loop for the outer edge of the rectangle runs counterclockwise, while the trimming loop for the punched-out hole runs clockwise. If you use more than one curve to define a single trimming loop, the curve segments must form a closed loop (that is, the endpoint of each curve must be the starting point of the next curve, and the endpoint of the final curve must be the starting point of the first curve). If the endpoints of the curve are sufficiently close together but not exactly coincident, they will be coerced to match. If the endpoints are not sufficiently close, an error results (see gluNurbsCallback). If a trimming loop definition contains multiple curves, the direction of the curves must be consistent (that is, the inside must be to the left of all of the curves). Nested trimming loops are legal as long as the curve orientations alternate correctly. If trimming curves are self-intersecting, or intersect one another, an error results. If no trimming information is given for a NURBS surface, the entire surface is drawn. EXAMPLE
This code fragment defines a trimming loop that consists of one piecewise linear curve, and two NURBS curves: gluBeginTrim(nobj); gluPwlCurve(..., GLU_MAP1_TRIM_2); gluNurbsCurve(..., GLU_MAP1_TRIM_2); gluNurbsCurve(..., GLU_MAP1_TRIM_3); gluEndTrim(nobj); SEE ALSO
gluBeginSurface(3G), gluNewNurbsRenderer(3G), gluNurbsCallback(3G), gluNurbsCurve(3G), gluPwlCurve(3G) GLUBEGINTRIM(3G)
All times are GMT -4. The time now is 12:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy