From: Zinger on
On Dec 3, 12:47 pm, Bill Marcum <marcumb...(a)bellsouth.net> wrote:
> On 2009-12-03, Zinger <zmas...(a)gmail.com> wrote:> Hi All,
>
> > I want to execute ls <filename> with a switch that should fetch all
> > files created with that name and are older than one day.
>
> > Pls help
>
> There is no creation time in Unix.
> find . -name foobar  \( -mtime +1 -o -ctime +1 -o -atime +1 \) -print

Hi All,

I apologize if I have not put the question correctly.

In a particular directory there are files with names as following:-

capz.1234
capz.3456
capz.6789

With ls I want to fetch files that have time stamp of "not within the
last 24 hours".

I do not want to use find as if I do find . -name "capz*", it
recursively finds it in subdriectories as well.

Hope it is clear

Thanks
From: pk on
Zinger wrote:

> In a particular directory there are files with names as following:-
>
> capz.1234
> capz.3456
> capz.6789
>
> With ls I want to fetch files that have time stamp of "not within the
> last 24 hours".

As others have said already, you should define what you mean by "timestamp".
A file has usually three different "timestamps": modification time, access
time, and change time.

> I do not want to use find as if I do find . -name "capz*", it
> recursively finds it in subdriectories as well.

Many implementations of find can be give options to limit the scope of their
search. Read the man page of your find to see if it supports options like -
maxdepth and -mindepth.
From: Ed Morton on
On Dec 3, 12:45 pm, Zinger <zmas...(a)gmail.com> wrote:
> On Dec 3, 12:47 pm, Bill Marcum <marcumb...(a)bellsouth.net> wrote:
>
> > On 2009-12-03, Zinger <zmas...(a)gmail.com> wrote:> Hi All,
>
> > > I want to execute ls <filename> with a switch that should fetch all
> > > files created with that name and are older than one day.
>
> > > Pls help
>
> > There is no creation time in Unix.
> > find . -name foobar  \( -mtime +1 -o -ctime +1 -o -atime +1 \) -print
>
> Hi All,
>
> I apologize if I have not put the question correctly.
>
> In a particular directory there are files with names as following:-
>
> capz.1234
> capz.3456
> capz.6789
>
> With ls I want to fetch files that have time stamp of "not within the
> last 24 hours".

"Which time stamp?", though, is the question everyone's been asking
you. There is no creation timestamp in UNIX so are yu looking for
modificatio time stamp or access time stamp or something else?

>
> I do not want to use find as if I do find . -name "capz*", it
> recursively finds it in subdriectories as well.
>
> Hope it is clear
>
> Thanks

man find and look for "-maxdepth".

Ed.
From: Zinger on
On Dec 3, 1:51 pm, Ed Morton <mortons...(a)gmail.com> wrote:
> On Dec 3, 12:45 pm, Zinger <zmas...(a)gmail.com> wrote:
>
>
>
> > On Dec 3, 12:47 pm, Bill Marcum <marcumb...(a)bellsouth.net> wrote:
>
> > > On 2009-12-03, Zinger <zmas...(a)gmail.com> wrote:> Hi All,
>
> > > > I want to execute ls <filename> with a switch that should fetch all
> > > > files created with that name and are older than one day.
>
> > > > Pls help
>
> > > There is no creation time in Unix.
> > > find . -name foobar  \( -mtime +1 -o -ctime +1 -o -atime +1 \) -print
>
> > Hi All,
>
> > I apologize if I have not put the question correctly.
>
> > In a particular directory there are files with names as following:-
>
> > capz.1234
> > capz.3456
> > capz.6789
>
> > With ls I want to fetch files that have time stamp of "not within the
> > last 24 hours".
>
> "Which time stamp?", though, is the question everyone's been asking
> you. There is no creation timestamp in UNIX so are yu looking for
> modificatio time stamp or access time stamp or something else?
>
>
>
> > I do not want to use find as if I do find . -name "capz*", it
> > recursively finds it in subdriectories as well.
>
> > Hope it is clear
>
> > Thanks
>
> man find and look for "-maxdepth".
>
>     Ed.

Thanks Guys. maxdepth has solved this
From: Glenn Jackman on
At 2009-12-03 01:45PM, "Zinger" wrote:
> In a particular directory there are files with names as following:-
>
> capz.1234
> capz.3456
> capz.6789
>
> With ls I want to fetch files that have time stamp of "not within the
> last 24 hours".
>
> I do not want to use find as if I do find . -name "capz*", it
> recursively finds it in subdriectories as well.

You *can* use find.

find . \( -type d ! -name . -prune \) -o \
-type f -name capz\* -mtime +1 -print

ref http://groups.google.ca/group/comp.unix.shell/msg/459edeb78baa41be

I have a (bash) function for this:

findin() {
local dir="${1:-.}" # if no args, look in "."
dir="${dir%/}" # strip trailing slash from dir
shift 1
find "$dir" \( -type d ! -name "$dir" -prune \) -o "$@" -print
}

So,

findin . -type f -name capz\* -mtime +1

--
Glenn Jackman
Write a wise saying and your name will live forever. -- Anonymous
First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5
Prev: Strip path to get filename
Next: touch to strip extension.