LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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


Reply
  Search this Thread
Old 01-14-2005, 02:34 AM   #1
izza_azhar
LQ Newbie
 
Registered: Jan 2005
Location: malaysia
Posts: 18

Rep: Reputation: 0
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
.
 
Old 01-14-2005, 03:51 AM   #2
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
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.
 
Old 01-15-2005, 06:31 PM   #3
twantrd
Senior Member
 
Registered: Nov 2002
Location: CA
Distribution: redhat 7.3
Posts: 1,440

Rep: Reputation: 52
Oh wow, didn't know that existed. Thanks!

-twantrd
 
Old 01-16-2005, 08:50 AM   #4
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
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...
 
Old 01-16-2005, 02:25 PM   #5
twantrd
Senior Member
 
Registered: Nov 2002
Location: CA
Distribution: redhat 7.3
Posts: 1,440

Rep: Reputation: 52
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
 
Old 01-16-2005, 05:44 PM   #6
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
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.
 
Old 01-16-2005, 10:12 PM   #7
izza_azhar
LQ Newbie
 
Registered: Jan 2005
Location: malaysia
Posts: 18

Original Poster
Rep: Reputation: 0
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!!
 
Old 01-16-2005, 10:53 PM   #8
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
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"
 
  


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
remove a folder created 3 days ago. eduac Linux - Software 4 10-17-2005 11:15 AM
Is Current FC3 Distro Same as 6 months ago rickh Fedora 4 05-06-2005 02:47 PM
Dial-up on RH9: worked two years ago alar Linux - Networking 2 04-30-2005 05:01 PM
Today's newbies to Linux vs. Five years ago (say) vharishankar General 40 03-23-2005 12:42 PM
Posted this a while ago... Grim Reaper Linux - Software 4 08-27-2004 10:09 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:18 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