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 12-14-2010, 01:42 PM   #16
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,925
Blog Entries: 44

Rep: Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159

Hi,

Quote:
Originally Posted by Dale255 View Post
Thank you very much.

I have the information I need to make this script. But it is just putting it together in to one that I don't understand.
Is there any one of those links that would be specificity good for that?
Since you are new to scripting then Bash Beginners Guide.
The Bash Reference Manual
 will provide useful detail.
Advanced Bash-Scripting Guide will lead you to further work and investigation.

So to answer your question, I would suggest all three. Other links that I provided will be of use to extend your Gnu/Linux experience.

 
Old 12-14-2010, 02:51 PM   #17
Dale255
LQ Newbie
 
Registered: Dec 2010
Posts: 13

Original Poster
Rep: Reputation: 0
Well with of help from a friend ( can't thank him enough ) I have came to this...

#/bin/bash

clear
date=$(date +%y%m%d)

echo "Making Backup Directory for $date..."
mkdir "$date"

echo "Backing up LOG files to $date..."
for i in *.log
do
cp "$i" "$date/"
done

echo "Compressing backup files for $date..."
tar cvzf "$date.tar.gz" "$date"

clear
echo "==================================="
echo " Backup Complete "
echo "-----------------------------------"
date
echo "==================================="

echo "Files backed up:"
tar -ztvf "$date.tar.gz"


All i need to do now i change it from making a directory to using the directory "weekXX" instead of it making a new directory.
Could anyone help with that?

Last edited by Dale255; 12-14-2010 at 03:31 PM.
 
Old 12-14-2010, 03:17 PM   #18
devnull10
Member
 
Registered: Jan 2010
Location: Lancashire
Distribution: Slackware Stable
Posts: 572

Rep: Reputation: 120Reputation: 120
You can remove your loop and just have

Code:
cp *.log $DATE/
Also, it's always a good idea not to use the name of commands as variable names either (eg "date") - can cause lots of confusion in the future!
 
Old 12-14-2010, 05:19 PM   #19
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,925
Blog Entries: 44

Rep: Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159
Hi,
Quote:
Originally Posted by Dale255 View Post
Well with of help from a friend ( can't thank him enough ) I have came to this...

Code:
#/bin/bash

clear
date=$(date +%y%m%d)

echo "Making Backup Directory for $date..."
mkdir "$date"

echo "Backing up LOG files to $date..."
for i in *.log
do
        cp "$i" "$date/"
done

echo "Compressing backup files for $date..."
tar cvzf "$date.tar.gz" "$date"

clear
echo "==================================="
echo "         Backup Complete "
echo "-----------------------------------"
date
echo "==================================="

echo "Files backed up:"
tar -ztvf "$date.tar.gz"
All i need to do now i change it from making a directory to using the directory "weekXX" instead of it making a new directory.
Could anyone help with that?
It would be best if you place the code snippets with the code tags # at the top of the reply window. This way your post is cleaner and easier to read. Notice the bash within code & quote for the whole reply above. Please use it to help us help you.

You do need to use unique names whenever writing code, be it scripting or other forms of code development. Uniqueness insures no conflicts or confusion(s).
 
Old 12-14-2010, 05:20 PM   #20
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Code:
wknum=$1
new_dir=week$wknum
Re your 'specificity' qn, out of all the things you've been recommended (all good btw) I'd say Rute guide is prob the best tutorial for beginners as far as example progs go. Some of the the otheres tend to just show individual techniques ie more of a ref than a tutorial. Nonetheless, have a look at them all and borrow bits as they suit you.
Also, in general, don't try to solve an entire task all in one go, break it down into small bits that need doing and play with cmds to just do each bit, then put them together later.
This is an HTML version of the man (manual) pages; easy to search http://linux.die.net/man/
 
1 members found this post helpful.
Old 12-14-2010, 05:56 PM   #21
Dale255
LQ Newbie
 
Registered: Dec 2010
Posts: 13

Original Poster
Rep: Reputation: 0
Very much appreciated chrism01.

Looks like I have enough reading for a life time on bash alone.
 
Old 12-14-2010, 07:11 PM   #22
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,925
Blog Entries: 44

Rep: Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159
Hi,

Quote:
Originally Posted by Dale255 View Post
Very much appreciated chrism01.

Looks like I have enough reading for a life time on bash alone.
Baby steps at first then you'll be walking in no time.

I've been in this field for years and still learn something new daily!
 
  


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
Variables and Mkvextract in a bash script and a good resource for bash help? gohmifune Linux - General 9 04-13-2011 08:37 AM
SSH connection from BASH script stops further BASH script commands tardis1 Linux - Newbie 3 12-06-2010 08:56 AM
[SOLVED] Using a long Bash command including single quotes and pipes in a Bash script antcore Linux - General 9 07-22-2009 11:10 AM
Strange if statement behaviour when using bash/bash script freeindy Programming 7 08-04-2008 06:00 AM
Is this possible (file archiving/tidying script) mrgreaper Linux - Newbie 3 07-25-2008 12:25 PM

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

All times are GMT -5. The time now is 07:49 AM.

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