nixCraft Linux Forum

nixCraft

Linux / UNIX 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 ...

Register free or login to your existing account and remove all advertisements.


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

Linux answers from nixCraft.


Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-08-2007, 11:37 AM
kasimani's Avatar
Senior Member
User
 
Join Date: Jul 2006
Location: India, Delhi
OS: CentOS, RedHat, Fedora, Ubuntu
Posts: 151
Thanks: 3
Thanked 1 Time in 1 Post
Rep Power: 4
kasimani is on a distinguished road
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
  #2 (permalink)  
Old 02-08-2007, 04:20 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,672
Thanks: 11
Thanked 240 Times in 180 Posts
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 Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote
  #3 (permalink)  
Old 02-08-2007, 04:45 PM
kasimani's Avatar
Senior Member
User
 
Join Date: Jul 2006
Location: India, Delhi
OS: CentOS, RedHat, Fedora, Ubuntu
Posts: 151
Thanks: 3
Thanked 1 Time in 1 Post
Rep Power: 4
kasimani is on a distinguished road
Send a message via Yahoo to kasimani
Default hi budy

thanks a ton,

it worked!!

thanks for assisting me!!!
Reply With Quote
Reply


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 Off


Similar Threads

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


All times are GMT +5.5. The time now is 12:59 PM.


Powered by vBulletin® Version 3.8.4 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2009 nixCraft. All rights reserved

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 37 38