- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- df script problem
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2002 10:11 PM
07-17-2002 10:11 PM
I would like to obtain the filesystem's allocated size, its usage and its number of free space. I'm reading a list of filesystems from a text file.
for i in `cat $1`
do
df -k|awk '{x=$2-$3}{print $7, $2, $3, x}'>> /tmp/restore/FSlist/$1.txt
grep -v "Mounted" /tmp/restore/FSlist/$1.txt
>> /tmp/restore/FSlist/$1.txt
done
I would like to remove the string "Mounted 1024 blocks Free 1024" on the file passwd by $1.txt and rewritting the same file with the removed string pattern.
However, the string above still appears in $1.txt file as:
Mounted 1024 blocks Free 1024
/ fs37/nwdv.crtr.1 17890 7887 888
... ( and the list continues with the same pattern appearing for each filesystem size displayed.
How do I remove the string "Mounted 1024 blocks Free 1024" from the file specified in $1?
Also I would need to insert the following attributes for each columns of the display:
Filesystem Disk-Allocated Disk-Used Disk-Free
Could someone show me how I could do this?
Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2002 10:47 PM
07-17-2002 10:47 PM
Re: df script problem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2002 10:49 PM
07-17-2002 10:49 PM
Re: df script problem
I need to also run this script on an IBM AIX platform. I believe bdf does not exists on AIX platform.
Any other ideas?
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2002 10:49 PM
07-17-2002 10:49 PM
Re: df script problem
Try
for i in `cat $1`
do
echo "Filesystem Disk-Allocated Disk-Used Disk-Free" >> >> /tmp/restore/FSlist/$1.txt
df -k|awk '{x=$2-$3}{print $7, $2, $3, x}'| grep -v Mounted >> tmp/restore/FSlist/$1.txt
done
I'm not at a workstation at the moment so can't test the results but give it a try
If it's not ok , post the results
HTH
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2002 11:00 PM
07-17-2002 11:00 PM
Re: df script problem
grep -v 'Mounted 1024 blocks Free 1024' FileThatHasToBeChanged > ChangedFile
This gives you a new file without the unwanted string
BB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2002 11:15 PM
07-17-2002 11:15 PM
Re: df script problem
I've tried with both your ways, and it did eliminate the "Mounted 1024 blocks Free 1024" pattern and displays the format :
Filesystem Disk-Allocated Disk-Used Disk-Free
However, it displays the format:
Filesystem Disk-Allocated Disk-Used Disk-Free
at every output for each filesystem i.e:
Filesystem Disk-Allocated Disk-Used Disk-Free
/fs12/shark/ 577263 89877 90987
Filesystem Disk-Allocated Disk-Used Disk-Free
/fs12/shark.ct/ 577298 89877 90887
(and the pattern continues)
Also the output above gets repeated over and over again.
My script had been to modified as follows:
echo >>"Filesystem Disk-Allocated Disk-Used Disk-Free"
for i in `cat $1`
do
df -k|awk '{x=$2-$3}{print $7, $2, $3, x}'>> /tmp/restore/FSlist/$1.txt
grep -v "Mounted" /tmp/restore/FSlist/$1.txt
>> /tmp/restore/FSlist/$1.txt
done
Could someone point my mistake please? I need to solve it urgently.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2002 11:28 PM
07-17-2002 11:28 PM
Re: df script problem
Sorry I though you wanted each entry to have the header
Filesystem Disk-Allocated Disk-Used Disk-Free
Which I why I put the echo "Filesystem Disk-Allocated Disk-Used Disk-Free" >>
Inside the loop
Just take it outside of the loop before the
for i in `cat $1`
The only thing i can see wrong is you have created variable $i which is basically every entry in your $1
Try this
echo "Filesystem Disk-Allocated Disk-Used Disk-Free" >> /tmp/restore/FSlist/$1.txt
for i in $(cat $1)
do
df -k $i |awk '{x=$2-$3}{print $7, $2, $3, x}'>> /tmp/restore/FSlist/$1.txt
grep -v "Mounted" /tmp/restore/FSlist/$1.txt
>> /tmp/restore/FSlist/$1.txt
done
HTH
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2002 11:36 PM
07-17-2002 11:36 PM
Re: df script problem
Whoops! missed out the grep -v
for i in $(cat $1)
do
df -k $i |awk '{x=$2-$3}{print $7, $2, $3, x}'| grep -v mounted >> /tmp/restore/FSlist/$1.txt
done
HTH
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2002 11:46 PM
07-17-2002 11:46 PM
Re: df script problem
I don't want to get into your parsing problem details, as already the others have engaged in, nor do I want to dissuade you from writing a kind of generic shell script disk free stat.
Just would like to ask if Perl would be an option to you?
I experienced whenever I've had to write something generic which is supposed to run on a multitude of platforms the easiest sollution would call for a Perl script (Perl isn't only limitted to Unices, but also runs on Win32, Mac...)
Just to draw your attention to some useful CPAN modules for your kind of "problem".
Have a look at
http://www.cpan.org/modules/by-module/Filesys/Filesys-DiskFree-0.06.readme
or
http://www.cpan.org/modules/by-module/Filesys/Filesys-DiskSpace-0.05.readme
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2002 12:09 AM
07-18-2002 12:09 AM
Re: df script problem
The output layout is better now, having the format:
Filesystem Disk-Allocated Disk-Used Disk-Free
and no more repeated outputs. However, instead of displaying details for a particular input file which contains a list of filesystems, it also displays the disk-usage of other filesystems which is not specified in the input file, but within the system.
The input file to $1 looks is as follows:
cat $1
/circuits/layout
/stor/physical
/stor/circuit_design
I'm running the script on a fileserver.
Any ideas on how I should solve it?
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2002 12:18 AM
07-18-2002 12:18 AM
SolutionLets say the file that contains your filesystems is in /tmp called /tmp/fsystem
Then at the beginning of your script
FILES=/tmp/fsystem
for i in $(cat $FILES)
do
df -k $i |awk '{x=$2-$3}{print $7, $2, $3, x}'| grep -v mounted >> /tmp/restore/FSlist/$1.txt
done
That way the script should only look at the contents of your file /tmp/fsystem
HTH
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2002 05:33 AM
07-19-2002 05:33 AM
Re: df script problem
How did you get on with your script ? Did the last input work for you ?
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2002 05:50 AM
07-19-2002 05:50 AM
Re: df script problem
If you want parsable output, use 'mi' instead (linked to 'di')
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2002 10:52 AM
07-19-2002 10:52 AM
Re: df script problem
I simply use
df -klP $(cat $1)
on both HPUX and Linux. I imagine it will also work on AIX and Solaris.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2002 11:13 AM
07-19-2002 11:13 AM
Re: df script problem
Try some of the scripts mentioned / attached in the link below,
http://forums.itrc.hp.com/cm/QuestionAnswer/0,,0x026250011d20d6118ff40090279cd0f9,00.html
There are a lot of useful scripts in that link.
Hope this helps.
regds