Sponsored Content
Full Discussion: Loop over variable content
Top Forums Shell Programming and Scripting Loop over variable content Post 302544506 by manolain on Thursday 4th of August 2011 04:21:24 AM
Old 08-04-2011
Hello guys,

Thanks very much for your replies, now I feel I am closer

I tried what you suggested, but it seems that I am losing lines when retrieving the information, let me explain:

My script is doing the following:

Code:
log_exec=`$path_ds_ex/dsjob -logdetail $proyecto $job`
#(doing this because need to use this many times later on)
 
numtimes=`echo $log_exec | grep "Waiting for job" | grep "to start" | wc -l `
echo $numtimes

Result for this is: 1


Otherwise, if I do this:

Code:
log_exec=`$path_ds_ex/dsjob -logdetail $proyecto $job`
 
numtimes=`$path_ds_ex/dsjob -logdetail $proyecto $job | grep "Waiting for job" | grep "to start" | wc -l `
echo $numtimes

Now result is correct: 24


On the other hand, I tried the code fpmurphy suggested, but got nothing at all!

Code:
echo "$log_exec" | while read a b c d e f; do
  if [[ "$a $b $c" == "Waiting for job"  && "$e $f" == "to start" ]]
    then
        echo "$d"
    fi
done

Can you please guys advice?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to replace a variable content

Hi, variable1="This is a car" Now I want to replace the content of variable1, "car" to "dog". Is there any simple command I can use. Thanks. Joseph (4 Replies)
Discussion started by: josephwong
4 Replies

2. Shell Programming and Scripting

Content of Content of a variable!

I got a sample BASH script like this : $ cat test MYVAR=$1 DUMMY1="This is tricky" DUMMY2=24 echo $ $ ./test DUMMY1 ./test: line 5: This is tricky: syntax error in expression (error token is "is tricky") **I was expecting the output as "This is tricky", ah! but no luck **But... (2 Replies)
Discussion started by: jaduks
2 Replies

3. Shell Programming and Scripting

Content of variable

I have a variable that contains filenames like this: variable="file_1.extension<blank>file_2.extension<blank>file_3.extension<blank>file_4.extension and so on" How can I make filenames to be separated by newline: (I tried Sed but it didn't worked well) file_1.extension file_2.extension... (6 Replies)
Discussion started by: MartyIX
6 Replies

4. Shell Programming and Scripting

addressing variable content...

I want to address a variable content whose name is/matches the content of a given other variable. i.e. set name=´sam´ set ${name}_age=´27´ So, by typing: echo ${name}_age I correctly obtain: sam_age By typing: echo $sam_age or echo ${sam_age} I correctly obtain: 27 But how can I... (3 Replies)
Discussion started by: sobolev
3 Replies

5. Shell Programming and Scripting

how to get the specified content of the text into a variable.

I am having one string like ./usr1/Server/temp/app.env ./usr1/Server/temp/upp/app.env ./usr1/Server/ORIG_temp/app.env ./usr1/Server/ORIG_temp/upp/app.env ./usr1/Server/work_temp_40/app.env ./usr1/Server/work_temp_40/upp/app.env ./usr1/fd/app.env ./usr1/PurgeArchive/app.env ./usr1/bm/bin/app.env... (6 Replies)
Discussion started by: dineshmurs
6 Replies

6. Shell Programming and Scripting

[SHELL: /bin/sh] For loop using variable variable names

Simple enough problem I think, I just can't seem to get it right. The below doesn't work as intended, it's just a function defined in a much larger script: CheckValues() { for field in \ Group_ID \ Group_Title \ Rule_ID \ Rule_Severity \ ... (2 Replies)
Discussion started by: Vryali
2 Replies

7. Shell Programming and Scripting

printing variable with variable suffix through loop

I have a group of variables myLINEcnt1 - myLINEcnt10. I'm trying to printout the values using a for loop. I am at the head banging stage since i'm sure it has to be a basic syntax issue that i can't figure out. For myIPgrp in 1 2 3 4 5 6 7 8 9 10; do here i want to output the value of... (4 Replies)
Discussion started by: oly_r
4 Replies

8. Shell Programming and Scripting

Array Variable being Assigned Values in Loop, But Gone when Loop Completes???

Hello All, Maybe I'm Missing something here but I have NOOO idea what the heck is going on with this....? I have a Variable that contains a PATTERN of what I'm considering "Illegal Characters". So what I'm doing is looping through a string containing some of these "Illegal Characters". Now... (5 Replies)
Discussion started by: mrm5102
5 Replies

9. Shell Programming and Scripting

[Solved] How to increment and add variable length numbers to a variable in a loop?

Hi All, I have a file which has hundred of records with fixed number of fields. In each record there is set of 8 characters which represent the duration of that activity. I want to sum up the duration present in all the records for a report. The problem is the duration changes per record so I... (5 Replies)
Discussion started by: danish0909
5 Replies

10. UNIX for Dummies Questions & Answers

Getting ls content into a file using variable

hi i just cant figure out how can i do this ls -lt > log.txt using $PWD what i mean is how can i get the ls command content into a file using $PWD variable? :confused: (4 Replies)
Discussion started by: chinababy
4 Replies
SLURMSTEPD(8)							 Slurm components						     SLURMSTEPD(8)

NAME
slurmstepd - The job step manager for SLURM. SYNOPSIS
slurmstepd DESCRIPTION
slurmstepd is a job step manager for SLURM. It is spawned by the slurmd daemon when a job step is launched and terminates when the job step does. It is responsible for managing input and output (stdin, stdout and stderr) for the job step along with its accounting and sig- nal processing. slurmstepd should not be initiated by users or system administrators. COPYING
Copyright (C) 2006 The Regents of the University of California. Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). CODE-OCEC-09-009. All rights reserved. This file is part of SLURM, a resource management program. For details, see <http://www.schedmd.com/slurmdocs/>. SLURM is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. SLURM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. SEE ALSO
slurmd(8) slurmstepd 2.0 September 2006 SLURMSTEPD(8)
All times are GMT -4. The time now is 10:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy