LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-28-2012, 03:58 AM   #16
cnitin
LQ Newbie
 
Registered: Mar 2012
Posts: 25

Original Poster
Rep: Reputation: Disabled

Hi gnashley

Code:
       12                              3   4                  56
conv1=((cat test.txt | awk '{print $1}') / (1024 * 1024 * 1024))
above shows that 1 and 6 are external opening and closing paranthesis

while 2 and 3 --- and 4 and 5 are internal paranthesis.

i think i am not missing the paranthesis
 
Old 03-28-2012, 04:04 AM   #17
cnitin
LQ Newbie
 
Registered: Mar 2012
Posts: 25

Original Poster
Rep: Reputation: Disabled
Hi gnashley

Code:
       12                              3   4                  56
conv1=((cat test.txt | awk '{print $1}') / (1024 * 1024 * 1024))
i think parenthesis are even.

 
Old 03-28-2012, 05:45 AM   #18
cnitin
LQ Newbie
 
Registered: Mar 2012
Posts: 25

Original Poster
Rep: Reputation: Disabled
Hi Guys

Here is the final script...

i was unable to convert the KBs to GBs in a single line as discussed in above replies..

so i dealt it with below code

Code:
#!/bin/sh

df |awk '{ print $4 "\t" $6 }'|grep -v -e shm -e boot > sp.txt

cat sp.txt | grep -v -e Avail -e oracle_home > sp1.txt

sed '1d' sp1.txt > sp2.txt

while read inputline
        do
                echo $inputline > test.txt
                input=`cat test.txt |awk '{print $1}'`
                if [[ $input -lt 52428800 ]]
                then
                conv1=`cat test.txt | awk '{print $1}'`
                ((mega=$conv1/1024))
                ((giga=$mega/1024))
                echo "Mount point `cat test.txt|awk '{print $2}'` has "$giga" GB"
                else
                conv2=`cat test.txt | awk '{print $1}'`
                ((mega=$conv2/1024))
                ((giga=$mega/1024))
                echo "inside else"
                echo "Mount point `cat test.txt|awk '{print $2}'` has "$giga" GB"
                fi
done < sp2.txt
Any help to shorten above code will be greatly appreciated.

Regards
 
Old 03-28-2012, 06:54 AM   #19
cnitin
LQ Newbie
 
Registered: Mar 2012
Posts: 25

Original Poster
Rep: Reputation: Disabled
Hi Guys a more refined version of above script is as follows.

Code:
#!/bin/sh

df |awk '{ print $4 "\t" $6 }'|grep -v -e shm -e boot > sp.txt

cat sp.txt | grep -v -e Avail -e oracle_home > sp1.txt

sed '1d' sp1.txt > sp2.txt

if [ -e  output.log ]
then
        rm -rf output.log
else
        echo "file does not exists"
fi


while read inputline
        do
                echo $inputline > test.txt
                input=`cat test.txt |awk '{print $1}'`
                if [[ $input -lt 52428800 ]]
                then
                conv1=`cat test.txt | awk '{print $1}'`
                ((mega=$conv1/1024))
                ((giga=$mega/1024))
                        if [[ $giga -eq 0 ]]
                        then
                        echo "Mount point `cat test.txt|awk '{print $2}'` has "$mega" MB available space" >> output.log
                        else
                        echo "Mount point `cat test.txt|awk '{print $2}'` has "$giga" GB available space" >> output.log
                        fi
                else
                conv2=`cat test.txt | awk '{print $1}'`
                ((mega=$conv2/1024))
                ((giga=$mega/1024))
                echo "inside else"
                echo "Mount point `cat test.txt|awk '{print $2}'` has "$giga" GB available space"
                fi

done < sp2.txt
Regards
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
checking disk space misterdanny Linux - Software 5 04-21-2009 03:20 PM
Best program for checking available disk space? TippyToes Linux - Software 5 11-16-2004 09:57 PM
Disk space checking script? jimieee Linux - General 2 04-01-2004 02:57 AM
Checking disk space timberwolf Linux - General 9 12-04-2003 01:18 AM
script for checking disk space pralaydesai Linux - Networking 3 03-25-2003 03:34 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration