How do l test for carriage return & Disk space usage


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How do l test for carriage return & Disk space usage
# 1  
Old 06-28-2005
How do l test for carriage return & Disk space usage

Hi,

I have just written a script in /bin/bash, however, l want to test if character is a carriage return or space. Also l want my script to be able to detect my disk space and send a mail if usage is more than 90% or send an alert.

Thanks

Kayode
# 2  
Old 06-28-2005
bdf or df du give information about disk usage.
For example:
Code:
 bdf . | awk '{ if(NR==2){print $5}}'

gives you the % free on the current disk.

'\015' is octal for ASCII 13 - carriage return.
You can use:
Code:
expr index $VAR '\015'

to get the position of a carriage return (0=none found) in the variable VAR.
# 3  
Old 06-29-2005
Disk Space Usage

I use this:
UsedSpace=`df -k . | awk '{print $5 }'| tail -1 | cut -d"%" -f1`

if [$UsedSpace -ge 90 ]
select the files that you want to remove
rm -f selected files
fi
# 4  
Old 07-01-2005
Thanx these scripts did work perfectly.
# 5  
Old 07-12-2005
How do you check all file system's disk usage and email threshold over 95%

I need 2 scripts that will e-mail me if thressholds are exceeded.

One is for disk usage and one is for cpu usage. I got the df -k . one to work obviously for the file system I was in, but I'd like a command that would go through all of the file systems on all my servers and report back without having to hard-code the file systems.

Renae
# 6  
Old 07-12-2005
Just capture the output of df -k (on Sun and Linux) or bdf (on HP) and carry out the check for each filesystem. A 'while do .. done' loop will do the job.
# 7  
Old 07-14-2005
Quote:
Originally Posted by jim mcnamara
Code:
 bdf . | awk '{ if(NR==2){print $5}}'

Code:
 bdf . | awk 'NR==2{print $5}'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Generate disk space usage email alert

hi all members I have a shell script to generate disk space usage email alert if threshold is more than 80 %, now the requirement changed to keep sending alert emails for every 5% incremental usage ........ Any help would be greatly appreciated. ex - 80% , 85% ,90%,95%,100% we should get an... (6 Replies)
Discussion started by: anil529
6 Replies

2. Shell Programming and Scripting

Need Generic command for disk space usage

Given this directory /web I need to get the current usage (in %) on Linux and Unix both using the same command on bash shell ? The command i tried was working on Unix (solaris) but does not filter the desired same value when run of Linux. My command df -h /web | awk '{print $5}' | sed -n... (5 Replies)
Discussion started by: mohtashims
5 Replies

3. Shell Programming and Scripting

Send Disk Space Usage Status via email

Hi Guys, Is there any way I can write a script that sends DISK SPACE USAGE STATUS via email once a week? Thanks, (5 Replies)
Discussion started by: g4v1n
5 Replies

4. UNIX Desktop Questions & Answers

Issue with disk space usage

Issue with disk space usage I have the following line in my "df -h" output: Filesystem Size Used Avail Capacity Mounted on /dev/ad4s1a 496M 495M -39M 109% / What is the issue with having 9% excess utilisation? How can I find out what this partition is... (2 Replies)
Discussion started by: figaro
2 Replies

5. Shell Programming and Scripting

Disk Usage - Space Used

Hi all, FreeBSD7.1 @ sh. In a backup script I am trying to get the blocks used by the backup once completed. I am using the function: #!/bin/sh spaceused() { du -d 0 "${1}" | awk -F"+" '{ print $1 } } to return the blocks used of said directory and contents. Via. command line... (7 Replies)
Discussion started by: Festus Hagen
7 Replies

6. Shell Programming and Scripting

strip carriage return & append next line

Hello everyone, I am trying to search a file for lines that start with 'ip:' and have a carriage return after(ip:$). I then want to remove the carriage return from that line and append the next line in the file to the line containing 'ip'. I tried doing this with SED, but had no luck. Any... (3 Replies)
Discussion started by: vada010
3 Replies

7. Shell Programming and Scripting

script to monitor disk space usage

Some times my disk space is used upto 100% due to the application logs . So this script is to monitor the disk space usage and wall message to the users about the disk space usage if it exceeds the limit set in the script. Here for example the limit is set to 80%. This job is added in cron to... (2 Replies)
Discussion started by: amitranjansahu
2 Replies

8. Shell Programming and Scripting

Insert a line including Variable & Carriage Return / sed command as Variable

I want to instert Category:XXXXX into the 2. line something like this should work, but I have somewhere the wrong sytanx. something with the linebreak goes wrong: sed "2i\\${n}Category:$cat\n" Sample: Titel Blahh Blahh abllk sdhsd sjdhf Blahh Blah Blahh Blahh Should look like... (2 Replies)
Discussion started by: lowmaster
2 Replies

9. UNIX for Dummies Questions & Answers

how to determine the disk space usage

how can we determine the disk space used by a certain directory? (1 Reply)
Discussion started by: gfhgfnhhn
1 Replies

10. UNIX for Dummies Questions & Answers

finding disk space usage

How would I go about finding the about of disk space occupied by a certain directory? For example, /u1/cvera => 530 MB Thanks =) (3 Replies)
Discussion started by: cvera8
3 Replies
Login or Register to Ask a Question