Solved

Adding date to filename in a shell script

Posted on 2004-04-25
2
3,213 Views
Last Modified: 2013-12-16
hi I have tar -cf /home/1.tar *.* in a script to do a Daly backup with I need is to change 1.tar to the date i.e. 1-2-04.tar etc i am guessing the clock or date commands would need to be used thanks
0
Comment
Question by:kingpin200004
2 Comments
 
LVL 57

Expert Comment

by:Pete Long
ID: 10911444
Theres a Perl Script here that includes the funtionality you are after?
http://www.imagefolio.com/resources/mods/backup/index.txt
Pete
0
 
LVL 1

Accepted Solution

by:
joesp earned 125 total points
ID: 10912602
Here's my little mysql backup script.  
#!/bin/sh
present=`date +%b%d%y`
mysqldump -uUSERNAME -pPASSWORD --databases THIS_ONE_DB > $present.sql

which produces files like
~
Feb1604.sql

god bless
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Network Interface Card (NIC) bonding, also known as link aggregation, NIC teaming and trunking, is an important concept to understand and implement in any environment where high availability is of concern. Using this feature, a server administrator …
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now