nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

Shell script for automatic conversion of files in tar files

This is a discussion on Shell script for automatic conversion of files in tar files within the Shell scripting forums, part of the Development/Scripting category; Hello i am new to shell script i need a shell script that sense the space is almost filled upto ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 02-08-2007, 10:37 AM
Member
User
 
Join Date: Jul 2006
Posts: 72
Rep Power: 0
kasimani
Send a message via Yahoo to kasimani
Default Shell script for automatic conversion of files in tar files

Hello

i am new to shell script

i need a shell script that sense the space is almost filled upto 80%, after then, directories in particular dir. get converted to tar files.

when i do df -h then following output come

Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
144G 2.0G 135G 2% / (This portion the shell script has to sense)
/dev/sda1 99M 15M 80M 16% /boot
none 2.0G 0 2.0G 0% /dev/shm

can anybody do this for me, it;s very urgent

thanks in advance
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 02-08-2007, 03:20 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Any distro with shell
Posts: 910
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

Try following code.

Code:
#!/bin/bash
line=$(df -h | egrep -v '^Filesystem' | head -1)
output=$(echo $line | awk '{ print $5}' | cut -d'%' -f1 )
if [ $output -ge 80 ]; then
  echo "Running tar command..."
  # add tar command below
else
  # do nothing :)
  :
fi
You need to add tar command as per your need
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote
  #3 (permalink)  
Old 02-08-2007, 03:45 PM
Member
User
 
Join Date: Jul 2006
Posts: 72
Rep Power: 0
kasimani
Send a message via Yahoo to kasimani
Default hi budy

thanks a ton,

it worked!!

thanks for assisting me!!!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
split files by specifying a string (bash shell) vikas027 Shell scripting 4 11-01-2007 04:22 PM
Script to extract some part of files: satish1482 Shell scripting 0 03-13-2007 05:30 PM
shell script to open log files and check for faults trueman82 Shell scripting 1 11-23-2006 02:35 AM
shell script that parses multiple log files and checks for a Anonymous Shell scripting 1 11-15-2006 09:38 PM
script for uploading files to a FTP server marinm Shell scripting 7 01-02-2006 07:35 PM


All times are GMT +5.5. The time now is 04:32 PM.


Powered by vBulletin® Version 3.7.2 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36