LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-07-2010, 01:09 PM   #1
pnmanojshenoy
Member
 
Registered: Jun 2008
Location: Cochin, India
Distribution: Debian,Ubuntu
Posts: 38

Rep: Reputation: 0
Script to compress


Hello,

Can some one help me to write a script to compress any file with 10 MB size to tar.gz

Say /var/log/tes directory has a file with 10 MB I want it to compress to tar.gz

Thanks
 
Old 06-07-2010, 01:19 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,623

Rep: Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964
Quote:
Originally Posted by pnmanojshenoy View Post
Hello,
Can some one help me to write a script to compress any file with 10 MB size to tar.gz

Say /var/log/tes directory has a file with 10 MB I want it to compress to tar.gz
Thanks
We will be glad to help you. Post what you've written so far, and where you're having problems. However, we are not going to write your script for you.

There are many bash scripting tutorials on the web, that you can easily find. As a hint, read the man pages for the find and tar commands, as they will give you all the info you need to find the files, and compress them. Use the pipe " | " to chain commands together.
 
Old 06-07-2010, 01:26 PM   #3
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
You may want to take a look at the logrotate command. I think it will do what you want.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
script to compress a directory and then delete older than 7 days replica88 Linux - General 3 02-03-2010 07:21 PM
How to make/configure script to extract, ecit and compress initrd.gz ?? linus72 Linux - General 14 10-22-2009 06:31 PM
script needed to compress files kingkhankk Linux - General 2 03-04-2008 11:20 AM
compress fs alaios Linux - General 5 09-07-2004 08:29 PM
compress Ownasaurus Linux - Software 4 09-12-2003 07:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:29 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration