Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
01-14-2005, 02:34 AM
|
#1
|
LQ Newbie
Registered: Jan 2005
Location: malaysia
Posts: 18
Rep:
|
3 month's ago date's
i would like to know on 3 month agos date:
my programme is such this
for file in ls ATK*
do
curr_date=`echo $file|cut -d'_' -f4|cut -d'.' -f1`
#echo $curr_date
if [[ $curr_date -le <3 month ago> ]]
then
mv $file temp/sampple
fi
done
its just simple..but dont know how to solvee it..
pleasee
.
|
|
|
01-14-2005, 03:51 AM
|
#2
|
Senior Member
Registered: Jan 2003
Posts: 2,786
|
The man pages are your friend ( man date)
This works on my system:
date -d "3 months ago"
You'll need to read the man page to understand what you're allowed to use in the date string.
|
|
|
01-15-2005, 06:31 PM
|
#3
|
Senior Member
Registered: Nov 2002
Location: CA
Distribution: redhat 7.3
Posts: 1,440
Rep:
|
Oh wow, didn't know that existed. Thanks!
-twantrd
|
|
|
01-16-2005, 08:50 AM
|
#4
|
Senior Member
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536
Rep: 
|
Quote:
Originally posted by twantrd
Oh wow, didn't know that existed. Thanks!
|
That surprises me, because I showed that quite extensively in your earlier thread on this subject...
|
|
|
01-16-2005, 02:25 PM
|
#5
|
Senior Member
Registered: Nov 2002
Location: CA
Distribution: redhat 7.3
Posts: 1,440
Rep:
|
Code:
That surprises me, because I showed that quite extensively
I didn't start that thread nor replied to it (or even looked at it). If I did, then I would've known
-twantrd
|
|
|
01-16-2005, 05:44 PM
|
#6
|
Senior Member
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536
Rep: 
|
Quote:
Originally posted by twantrd
Quote:
That surprises me, because I showed that quite extensively
|
I didn't start that thread nor replied to it (or even looked at it). If I did, then I would've known
|
I'm very sorry about that.
I was mistaking you for the original poster.
|
|
|
01-16-2005, 10:12 PM
|
#7
|
LQ Newbie
Registered: Jan 2005
Location: malaysia
Posts: 18
Original Poster
Rep:
|
i'm the original poster actually..
but why there's an error using the date function like
DATE=$(date -u "$1" +%Y-%m-%d) and the rest
the error is such
date: 0551-402 Invalid character in date/time specification.
i'm new in this programming language and i'm using GMT date .help me!!
|
|
|
01-16-2005, 10:53 PM
|
#8
|
Senior Member
Registered: Oct 2003
Posts: 3,057
Rep:
|
Here's a little diddy I made to show date differences.
Code:
#!/bin/bash
then=`date +%B" "%d" "%Y -d "-3 months"`
recent=`date +%B" "%d" "%Y -d "-2 day"`
now=`date +%B" "%d" "%Y`
tomorrow=`date +%B" "%d" "%Y -d "1 day"`
echo " Three months ago was $then"
echo " Two days ago was $recent"
echo " Todays date is $now"
echo " Tomorrows date is $tomorrow"
|
|
|
All times are GMT -5. The time now is 05:19 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|