Unix/Linux
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   Web Development Archives FAQs Unix/Linux

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Web Development Archives Sponsor:
  #1  
Old July 3rd, 2008, 02:09 PM
text-dude
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
How to find all files between midnight and 08.00 am?

Hi,

Question: How to find all files between midnight and 08.00 am? How is
it? Is there any difference on creation date, modification date and
similar?

When I've found these files, I want to change their date manually


Any help?

Reply With Quote
  #2  
Old July 4th, 2008, 06:01 AM
pk
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
How to find all files between midnight and 08.00 am?

Thursday 3 July 2008 20:58, text-dude wrote:

Hi,
>

Question: How to find all files between midnight and 08.00 am? How is
it? Is there any difference on creation date, modification date and
similar?
>

When I've found these files, I want to change their date manually

You can do something like (with GNU find)

find /basedir -type f -printf '%p %CH:%CM\n' |
awk '$NF>="00:00" && $NF<="08:00" && NF--'

to get a list of such files.

--
All the commands are tested with bash and GNU tools, so they may use
nonstandard features. I try to mention when something is nonstandard (if
I'm aware of that), but I may miss something. Corrections are welcome.

Reply With Quote
  #3  
Old July 5th, 2008, 07:39 AM
pk
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
How to find all files between midnight and 08.00 am?

Saturday 5 July 2008 14:27, pk wrote:

for the test, but we're not interested in anymore). If we decrement the
value of NR (which represents the number of fields in the line), awk
thinks that the line has one field less. Since the overall value of the
expression is nonzero (all the tests have been successful, and NF is still
0, since it was at least 2 before), awk prints the (shortened) line.

Note that both solutions will fail if you have filenames with >= two
consecutive spaces in them.

--
All the commands are tested with bash and GNU tools, so they may use
nonstandard features. I try to mention when something is nonstandard (if
I'm aware of that), but I may miss something. Corrections are welcome.

Reply With Quote
  #4  
Old July 5th, 2008, 07:39 AM
pk
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
How to find all files between midnight and 08.00 am?

Saturday 5 July 2008 14:08, text-dude wrote:

Why does it come up with such programming crap, when I wanted to see
the switches of /usr/xpg4/bin/find ?

Sorry, I misread your output. , it's programming stuff, you're correct. To
get find's man page, try

man 1 find

if that doesn't work, your system probably does not have a man page for find
installed. You may also try

find -h
find

to get an usage summary, but they are not guaranteed to work either.


Reply With Quote
  #5  
Old July 6th, 2008, 12:19 PM
pk
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
How to find all files between midnight and 08.00 am?

Sunday 6 July 2008 18:49, James Kanze wrote:

>$ find /basedir -type f -printf '%p %CH:%CM\n' | awk '$NF>="00:00"
>&& $NF<="08:00" && NF--'
>find: bad option -printf
>find: [-H | -L] path-list predicate-list
>

All that means is that you are using Unix, and not some hacked
version; the Posix standard find doesn't have a -printf option.
And of course, you don't need it here anyway; awk is quite
capable of comparing any field, and -ls is standard for find.

My understanding is that -ls is NT standard. And, furthermore, with -ls
there is no way to print the file's access and change time. For those, you
have to use find -exec ls -l{u,c}.

--
All the commands are tested with bash and GNU tools, so they may use
nonstandard features. I try to mention when something is nonstandard (if
I'm aware of that), but I may miss something. Corrections are welcome.

Reply With Quote
  #6  
Old July 6th, 2008, 01:00 PM
pk
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
How to find all files between midnight and 08.00 am?

Sunday 6 July 2008 19:34, James Kanze wrote:

Yes. Newlines are even more of a problem than spaces. Nul
characters will often cause problems as well

AFAIK, nul are illegal in filenames (unless you have a corrupted filesystem,
of course).

That's where GNU utilities, with their ability to output nul-delimited lists
of filenames can be safer than PSIX.


Reply With Quote
  #7  
Old July 7th, 2008, 06:20 AM
pk
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
How to find all files between midnight and 08.00 am?

Monday 7 July 2008 10:44, text-dude wrote:

>sys: ~/ $ ls -l ./fig3011_SEQ.png
>-rw-r 1 sname32 sna 16628 Jun 1 16:54 ./
>fig3011_SEQ.png
>>

>That's probably due to localization issues. Try with
>>

>LC_ALL=en_US ls -l filename
>

No, doesn't work. What does your pc do? Does it enter the year when >
6 months or not?

No, I get this:

$ LC_ALL=en_US ls -l /bin

-rwxr-xr-x 1 root root 5404 2007-12-23 16:32 mountpoint
-rwxr-xr-x 1 root root 63144 2008-04-28 09:57 mv
-rwxr-xr-x 1 root root 112552 2008-07-02 10:29 nano
-rwxr-xr-x 1 root root 78976 2007-03-22 10:16 netstat


With C/PSIX locale I get this:

$ LC_ALL=C ls -l /bin

-rwxr-xr-x 1 root root 5404 Dec 23 2007 mountpoint
-rwxr-xr-x 1 root root 63144 Apr 28 09:57 mv
-rwxr-xr-x 1 root root 112552 Jul 2 10:29 nano
-rwxr-xr-x 1 root root 78976 Mar 22 2007 netstat


That's whay I thought it could be a localization issue. Make sure the en_US
locale is installed on your system doing "locale -a".

--
All the commands are tested with bash and GNU tools, so they may use
nonstandard features. I try to mention when something is nonstandard (if
I'm aware of that), but I may miss something. Corrections are welcome.

Reply With Quote
  #8  
Old July 7th, 2008, 07:01 AM
pk
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
How to find all files between midnight and 08.00 am?

Monday 7 July 2008 13:14, James Kanze wrote:

The output in any locale except PSIX is implementation defined.
I'm getting the C/PSIX output in en_US.utf8 here, both under
Linux (Red Hat) and Solaris; on my Linux box at home (SuSE), I'm
pretty sure I've seen your output, and I think the locale I use
there is also en_US.utf8. AS I said, however, except in the
locale PSIX, the output is implementation defined, and may
vary.

course. But still, the P might be able to find a locale that produces an
output that can be processed. Mine was just an example, to make the point
that the output can vary depending on the locale used.

If you're writing shell scripts, one of the first things
you should do at the beginning is to set the locale to PSIX, so
you know what to expect.

Many people D want localized outputs, so they do NT set the locale to
PSIX. In this case, the P might be able to get a processable output by
using a non-PSIX locale.

--
All the commands are tested with bash and GNU tools, so they may use
nonstandard features. I try to mention when something is nonstandard (if
I'm aware of that), but I may miss something. Corrections are welcome.

Reply With Quote
  #9  
Old July 8th, 2008, 08:01 AM
pk
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
How to find all files between midnight and 08.00 am?

Tuesday 8 July 2008 14:12, text-dude wrote:

>That's whay I thought it could be a localization issue. Make sure the
>en_US locale is installed on your system doing "locale -a".
>

You're right
>

It doesn't show up, so I guess it's not installed and ignores my
"en_US" setting, thus it just behaves in a "default" manner Neither
anything with "en" nor "us" is installed

Well, see what you have and try them one by one (if they are more than one,
of course :-)). It won't hurt anyway, and you might find one that works
(meaning "produce an easily parsable output").

Also, see if you have the "stat" utility on your system. If so, you can
perhaps do something like

find /basedir -type f -print -exec stat -c %x \{\} \; | awk '{getline nl;
dd=substr(nl,12,5); if ((dd>="00:00")&&(dd<="08:00")) print}'

to get a list similar to the one you got with my first solution,
assuming "stat" accepts the same options as GNU stat, and outputs the same
format (which of course cannot be assumed, and may not be true). If
your "stat" supports -c, the formats are %x, %y and %z to get access,
modification and change time resplectively.

--
All the commands are tested with bash and GNU tools, so they may use
nonstandard features. I try to mention when something is nonstandard (if
I'm aware of that), but I may miss something. Corrections are welcome.

Reply With Quote
Reply

Viewing: Web Development Archives FAQs Unix/Linux > How to find all files between midnight and 08.00 am?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway