Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Portage & Programming
  • Search

Scripting question

Problems with emerge or ebuilds? Have a basic programming question about C, PHP, Perl, BASH or something else?
Post Reply
Advanced search
4 posts • Page 1 of 1
Author
Message
Gwyd10n
n00b
n00b
User avatar
Posts: 41
Joined: Mon Jun 09, 2003 3:22 pm
Location: Long Beach

Scripting question

  • Quote

Post by Gwyd10n » Wed Jul 13, 2005 2:43 pm

Greetings all..

I am not sure if this is the right place for this or not so here goes...

I am working on a script which needs to be able to look in a directory for files created that day and copy them elsewhere. The name format of the files is the same execpt for the last 4 characters which are random numbers so I need to be able to pull based on date.
Any ideas as to the best way to handle this?

would 'find' be the way to go or should I use something else?
---------------------
AMD 64 +3200
512 MB PC3200
MSI K8TNEO-FIS2R
Geforce FX 5200 128MB
Top
msalerno
Veteran
Veteran
User avatar
Posts: 1338
Joined: Tue Dec 17, 2002 6:20 pm
Location: Sweating in South Florida

  • Quote

Post by msalerno » Wed Jul 13, 2005 3:18 pm

You could use find. You will want to change the ok to exec once you get everything working, but the below line will:

-type f - Find regular files
-daystart - measure time from the beginning of today rather than from 24 hours ago.
-mtime - last modified x days ago - also check out ctime, atime
Then of course, it moves the files to /tmp

You would need to run this command at 12:00am, but it should do it.

find . -type f -daystart -mtime 1 -ok mv {} /tmp \;
Top
Gwyd10n
n00b
n00b
User avatar
Posts: 41
Joined: Mon Jun 09, 2003 3:22 pm
Location: Long Beach

  • Quote

Post by Gwyd10n » Wed Jul 13, 2005 6:02 pm

msalerno wrote:You could use find. You will want to change the ok to exec once you get everything working, but the below line will:

-type f - Find regular files
-daystart - measure time from the beginning of today rather than from 24 hours ago.
-mtime - last modified x days ago - also check out ctime, atime
Then of course, it moves the files to /tmp

You would need to run this command at 12:00am, but it should do it.

find . -type f -daystart -mtime 1 -ok mv {} /tmp \;
Ok this works, after a fashion, it is prompting me to ok the copy. I need it to be automated as I want this to run in a nightly cron job...
---------------------
AMD 64 +3200
512 MB PC3200
MSI K8TNEO-FIS2R
Geforce FX 5200 128MB
Top
teknomage1
Veteran
Veteran
User avatar
Posts: 1239
Joined: Tue Aug 05, 2003 10:05 pm
Location: Los Angeles, CA

  • Quote

Post by teknomage1 » Thu Jul 14, 2005 3:52 am

from man find:

Code: Select all

 -ok command ;
       Like -exec but ask the user first (on the standard input); 
       if the response does not start with `y' or `Y',  
       do  not  run  the command, and return false.
Top
Post Reply

4 posts • Page 1 of 1

Return to “Portage & Programming”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic