Sponsored Content
Top Forums Shell Programming and Scripting Space storage shell script issue! Post 302550187 by itkamaraj on Thursday 25th of August 2011 01:40:24 AM
Old 08-25-2011
Code:
 
nawk '/%/ {if(length($(NF-1))> 2) {a=substr($(NF-1),1,length($(NF-1))-1); if(a > 30){print $0}}}'

/%/  --> Match % and process the lines which is having %
$(NF-1) --> Print the value of (last - 1) column value (disk usage column)
length($(NF-1)) --> Get the length of the disk usage column.
if(length($(NF-1))> 2  --> check the length is greater than 2 ( It will eliminate the usage which is less than 10%)
a=substr($(NF-1),1,length($(NF-1))-1);  --> Strip the % value from the disk usage column ( eg: 85% to 85 )
then check a > 30, then print the line.
More example for understaing :
echo "abc edf ghi" | awk '{ print $NF }'            # prints the last record value
echo "abc edf ghi" | awk '{ print $(NF-1) }'  # prints the last-1 record value
echo "abc edf ghi" | awk '{ print $(NF-2) }'  # prints the last-2 record value
echo "abcd efg hi" | awk '{print length($1)}'  # prints the lenght of first record
echo "abcd efg hi" | awk '{print length($2)}'  # prints the lenght of second record
echo "abcd efg hi" | awk '{print length($3)}'  # prints the lenght of third record
echo "abcdefg" | awk '{ print substr($0,1,2)}'   # prints 2 letters from the 1st position

 

8 More Discussions You Might Find Interesting

1. AIX

how do I increase the storage space I am new to AIX

Host Name - xxxxxxx IP Address - xxxxxxxxx Alert Msg - The percentage of available storage space (DMXMemory) is low (49.54374442289481 percent). Time received - 14:23 Time Logged - 14:55 Suggested Group - MR-UNIX (5 Replies)
Discussion started by: Nyiko
5 Replies

2. Shell Programming and Scripting

Shell script partitions space monitor

Hello friends, I'm newbie in shell scripting... Until now i have this script: #!/bin/sh emailok = email1@domain.com emailissue = email2@domain.com limit="50" df -h | grep -vE '^Filesystem' | awk '{print $1 " " $4 " " $5}'|while read val do partition=$(echo $val | awk '{print... (9 Replies)
Discussion started by: john_doe
9 Replies

3. Shell Programming and Scripting

Passing Parameter containing space in between to Shell Script

Hi, I have one shell script which use two parameter however one of its parameter have space in between. eg. a.sh 20110114 b c d here b c d is one parameter I used 'b c d' but its not giving correct result. Also i tried b\c\d but this one also didnt work. Any help would be... (5 Replies)
Discussion started by: diehard
5 Replies

4. Solaris

Storage issue on T5220

We have one box T5220 which was assigned 2x100G Luns but i have a strange problem if i use powermt display it only shows me one card but cfgadm, fcinfo commands shows 2 dual port cards as up. What could be the reason for it. I already did a re-configure reboot but that didn't help. Can anyone help... (1 Reply)
Discussion started by: fugitive
1 Replies

5. Shell Programming and Scripting

Help with Disk Space script in bash shell

Hi Guys, I'm a newb at shell scripting and successfully attempted a small disk space script (victory!!) but i'm wondering whether it actually takes into consideration KB,MB,GB. Please take a look at the script and advise. ##script to check if file sys has reached threshold. ... (3 Replies)
Discussion started by: Irishboy24
3 Replies

6. Shell Programming and Scripting

Shell Script to Abort if file name has space.

Hi, In my shell script I use the following code to copy files from one directory to other. for file in `ls`; do #----------------- Copy Files From INDIR to OUTDIR -------------# echoen "Copying File ${INDIR}/$file to ${OUTDIR}/${file}" cp ${INDIR}/$file ... (4 Replies)
Discussion started by: pinnacle
4 Replies

7. Shell Programming and Scripting

Print 1 to 10 with space in shell script

Hi, I want to print 1 to 10 or upto any number sequentially with space in a single line. Like, 1 2 3 4 5 6 7 ...... In shell script only.. Can anyone plz help me. Thanks: (14 Replies)
Discussion started by: arup1980
14 Replies

8. Red Hat

Total storage space and Serial number

Hi, Could you please tell me the commands to find Total storage space and Serial number of Linux server. OS -- Red Hat Enterprise Linux Server release 6.6 (Santiago) This is 2 node cluster. Regards, Maddy (1 Reply)
Discussion started by: Maddy123
1 Replies
SCRIPT(1)						    BSD General Commands Manual 						 SCRIPT(1)

NAME
script -- make typescript of terminal session SYNOPSIS
script [-a] [-c COMMAND] [-f] [-q] [-t] [file] DESCRIPTION
Script makes a typescript of everything printed on your terminal. It is useful for students who need a hardcopy record of an interactive session as proof of an assignment, as the typescript file can be printed out later with lpr(1). If the argument file is given, script saves all dialogue in file. If no file name is given, the typescript is saved in the file typescript. Options: -a Append the output to file or typescript, retaining the prior contents. -c COMMAND Run the COMMAND rather than an interactive shell. This makes it easy for a script to capture the output of a program that behaves differently when its stdout is not a tty. -f Flush output after each write. This is nice for telecooperation: One person does `mkfifo foo; script -f foo' and another can super- vise real-time what is being done using `cat foo'. -q Be quiet. -t Output timing data to standard error. This data contains two fields, separated by a space. The first field indicates how much time elapsed since the previous output. The second field indicates how many characters were output this time. This information can be used to replay typescripts with realistic typing and output delays. The script ends when the forked shell exits (a control-D to exit the Bourne shell (sh(1)), and exit, logout or control-d (if ignoreeof is not set) for the C-shell, csh(1)). Certain interactive commands, such as vi(1), create garbage in the typescript file. Script works best with commands that do not manipulate the screen, the results are meant to emulate a hardcopy terminal. ENVIRONMENT
The following environment variable is utilized by script: SHELL If the variable SHELL exists, the shell forked by script will be that shell. If SHELL is not set, the Bourne shell is assumed. (Most shells set this variable automatically). SEE ALSO
csh(1) (for the history mechanism), scriptreplay(1). HISTORY
The script command appeared in 3.0BSD. BUGS
Script places everything in the log file, including linefeeds and backspaces. This is not what the naive user expects. AVAILABILITY
The script command is part of the util-linux-ng package and is available from ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/. Linux July 30, 2000 Linux
All times are GMT -4. The time now is 06:11 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy