LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
LinkBack Search this Thread
Old 10-18-2007, 10:14 AM   #1
send2rawat
LQ Newbie
 
Registered: Jan 2007
Posts: 16

Rep: Reputation: 0
forward to another directory


I have some text files in a directory.
I want to read those files one by one.
I just want that if i had read that file once then it should be transfed to another folder.
 
Old 10-18-2007, 12:56 PM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian Squeeze
Posts: 5,698

Rep: Reputation: 287Reputation: 287Reputation: 287
You could probably do it with a shell script.

In *nix, you can't tell directly the creation time of a file. But, there are three times you can determine:
1) ctime (change time) - the time when changes were made to the file's inode (ownership, permissions, etc). When the file is first created, ctime is set. If inode properties are changed after creation, ctime changes. For new files, consider ctime equal to creation time. The output of 'ls -lc' shows ctime.

2) atime (access time) - the time the file was last accessed. 'ls -lu' shows atime.

3) mtime (modification time) - the time the file was last modified. 'ls -l' shows mtime.

So, for new files in the folder, your script could compare the output of 'ls -lc' to 'ls -lu', and if atime is greater than ctime (i.e. later than ctime) then you have accessed the file; move it to another folder.

In Linux, you also have the 'stat' command, which shows all three times. So, instead of comparing 'ls -lc' to 'ls -lu', your script could use the output of stat, and if atime is greater than ctime, move the file. You would probably want to use awk to compare the date/time fileds of ctime and atime.
 
Old 10-18-2007, 01:01 PM   #3
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 62
What is reading the files?
 
  


Reply

Tags
directory, forward


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Username & Password Sync Fedora Directory and Microsoft Active Directory karnac01 Fedora 4 07-19-2010 12:51 AM
LXer: Directory services made easy with Fedora Directory Server LXer Syndicated Linux News 0 12-08-2006 03:54 AM
.forward file not working for user having it's home directoryon NFS mounted directory skverma_in Linux - General 0 02-14-2005 02:54 AM
I want .forward to not forward attachments nigelj12 Linux - Software 1 09-30-2004 03:13 PM
cant see .forward file in home directory >> mail forward/copy steve_babbage Linux - Newbie 0 03-02-2004 06:25 AM


All times are GMT -5. The time now is 01:30 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration