Sponsored Content
Full Discussion: Df -h results in a loop
Top Forums Shell Programming and Scripting Df -h results in a loop Post 302973669 by Aia on Thursday 19th of May 2016 10:13:18 PM
Old 05-19-2016
Quote:
Originally Posted by Abu Rayane
Thank you guys for your effort, but I found a little mistake in cero code:




This is the mistake

Code:
str.sh: line 8: syntax error near unexpected token `<'
str.sh: line 8: `done < <(df -h | awk 'NR>2 { print $1 " " $5 }')'

Only Bash, Zsh and Ksh93 supports process substitution, which is what the <(...) means. Since you are invoking it with sh, judging by this # sh disk.sh , I suggest you use the command grouping

Here's an example using your original post #1

Code:
df -h | awk 'NR>2 { print $1 " " $5 }' |
{
    while read output
    do
        res=$(echo $output | awk '{ print $2}')
        useSpPer=${useSpPer}'-'$res

        echo 'use '$useSpPer
        echo 'res '$res
    done
    echo 'final '$useSpPer
}

This User Gave Thanks to Aia For This Post:
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl - Iterating a hash through a foreach loop - unexpected results

i've reworked some code from an earlier post, and it isn't working as expected i've simplified it to try and find the problem. i spent hours trying to figure out what is wrong, eventually thinking there was a bug in perl or a problem with my computer. but, i've tried it on 3 machines with the... (5 Replies)
Discussion started by: quantumechanix
5 Replies

2. Shell Programming and Scripting

2 CMD results on the same line while rexing in a loop

Folks, I have a 3 problems. In a sh script, I call a server name from a list and rex to a distant machine to get the boot date. for i in `cat list` do (echo "$i|"; /bin/rexsh $i -l bozo -t10 who -b | cut -d" " -f14-16) >>getBootTimes.out sleep 1 done The results are on 2 lines instead... (8 Replies)
Discussion started by: linux_lou
8 Replies

3. Shell Programming and Scripting

doing a for loop adding up the results

Hi there If I run a 'swap -l' on my solaris box, i get swapfile dev swaplo blocks free /dev/dsk/c1t0d0s1 54,65 8 67119560 65655144 /dev/dsk/c1t0d0s2 54,65 8 33119522 32655122 I wanted to run a for loop adding up the totals of each column 4 , excluding the... (2 Replies)
Discussion started by: hcclnoodles
2 Replies

4. Shell Programming and Scripting

Not able to store the results of perl recursive function when applied under for loop

Hi Perl Gurus , need URGENT HELP PLEASE !!!!! I have one recursive Perl function which takes path of any directory as argument and returns array containing all the sub folders inside it recursively. Now the problem is that it works well if i use it with one time but the problem is that when... (0 Replies)
Discussion started by: anthriksh2000
0 Replies

5. Shell Programming and Scripting

Concatenate Loop Results

Hi, I have the following situation: Param1Values = AAAA,BBBB Param1=$(echo $Param1Values| tr "," "\n") for x in $Param1 do db2 select X from Y where Z IN ('$x') done Obviously the above will perform the select 'x' amount of times. Is there a way in which i can... (13 Replies)
Discussion started by: RichZR
13 Replies

6. Shell Programming and Scripting

Can ctag and cscope support recording search results and displaying the history results ?

Hello , When using vim, can ctag and cscope support recording search results and displaying the history results ? Once I jump to one tag, I can use :tnext to jump to next tag, but how can I display the preview search result? (0 Replies)
Discussion started by: 915086731
0 Replies

7. Shell Programming and Scripting

Loop through awk results

I have files structured in stanzas, whose title is '', and the rest couples of 'id: value'. I need to find text within the title and return the whole stanzas that match the title. The following works: awk 'BEGIN{RS="";IGNORECASE=1}/^\/' myfileI would need to count all of the occurences, though,... (7 Replies)
Discussion started by: hermes14
7 Replies

8. Shell Programming and Scripting

Narrowing sed Results in While Loop

find $SRC -type f -name *.emlx | while read FILE do if : then sed -n '/From/p' $FILE fi done > $DEST-output.txt The loop above spits out a .txt file with several lines that look like this: From: John Smith <jsmith@company.com> How can I narrow that sed result to spit out the email... (5 Replies)
Discussion started by: sudo
5 Replies

9. Shell Programming and Scripting

I want to add a variable for the results from the formula of one variable and results of another var

Good morning all, This is the file name in question OD_Orders_2019-02-19.csv I am trying to create a bash script to read into files with yesterdays date on the file name while retaining the rest of the files name. I would like for $y to equal, the name of the file with a formula output with... (2 Replies)
Discussion started by: Ibrahim A
2 Replies
OVRIMOS_RESULT_ALL(3)													     OVRIMOS_RESULT_ALL(3)

ovrimos_result_all - Prints the whole result set as an HTML table

SYNOPSIS
int ovrimos_result_all (int $result_id, [string $format]) DESCRIPTION
Prints the whole result set as an HTML table. PARAMETERS
o $result_id - A result identifier, returned by ovrimos_execute(3) or ovrimos_exec(3). o $format - Optional HTML attributes for the generated table element. RETURN VALUES
Returns the number of rows in the generated table. EXAMPLES
This will execute an SQL statement and print the result in an HTML table. Example #1 Prepare a statement, execute, and view the result <?php $conn = ovrimos_connect("db_host", "8001", "admin", "password"); if ($conn != 0) { echo "Connection ok!"; $res = ovrimos_prepare($conn, "select table_id, table_name from sys.tables where table_id = 7"); if ($res != 0) { echo "Prepare ok!"; if (ovrimos_execute($res, array(3))) { echo "Execute ok! "; ovrimos_result_all($res); } else { echo "Execute not ok!"; } ovrimos_free_result($res); } else { echo "Prepare not ok! "; } ovrimos_close($conn); } ?> Example #2 ovrimos_result_all(3) with meta-information <?php $conn = ovrimos_connect("db_host", "8001", "admin", "password"); if ($conn != 0) { echo "Connection ok!"; $res = ovrimos_exec($conn, "select table_id, table_name from sys.tables where table_id = 1"); if ($res != 0) { echo "Statement ok! cursor=" . ovrimos_cursor($res) . " "; $colnb = ovrimos_num_fields($res); echo "Output columns=" . $colnb . " "; for ($i=1; $i <= $colnb; $i++) { $name = ovrimos_field_name($res, $i); $type = ovrimos_field_type($res, $i); $len = ovrimos_field_len($res, $i); echo "Column " . $i . " name=" . $name . " type=" . $type . " len=" . $len . " "; } ovrimos_result_all($res); ovrimos_free_result($res); } ovrimos_close($conn); } ?> PHP Documentation Group OVRIMOS_RESULT_ALL(3)
All times are GMT -4. The time now is 02:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy