Re: Script help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Sep 20, 2008 at 10:36:13AM +1000, Cameron Simpson wrote:
> On 19Sep2008 15:51, NiftyFedora Mitch <niftyfedora@xxxxxxxxxxxx> wrote:
> | On Fri, Sep 19, 2008 at 3:43 PM, Cameron Simpson <cs@xxxxxxxxxx> wrote:
> | > On 19Sep2008 14:08, Dennis Kaptain <dkaptain@xxxxxxxxxxxx> wrote:
> | > | > > Can anyone rattle this off of the top of their head?
> | > | > `ls -t myfile*.txt | head -1` might work for you.
> [...]
> | And if the question was to tinker with a set of files
> | that was generated with a script like this?:
> 
> | #!/bin/bash
> |  cd /tmp
> |  mkdir tinker/ tinker/foo/ tinker/foo/bar/ tinker/foo/bletch/
> |  for I in tinker/ tinker/foo/ tinker/foo/bar/ tinker/foo/bletch/
> |  do
> |  touch $I/myfile387465893495643658734.txt
> |  touch $I/myfile387465893495643658734.txt
> |  touch $I/myfile547647453645635632454.txt
> |  touch $I/myfile563546356243546767546.txt
> |  touch $I/myfile465565634678567345656.txt
> |  touch $I/myfile456674567452345566345.txt
> |  touch $I/myfile563546356243546767546.txt
> |  done
> 
> What's your point here? That the files are in many directories? That
> the timestamps may not be far enough apart to discern? That there may
> be too many files to fit on a single command line? That the script calls
> for bash unnecessarily; the more portable sh is just fine? That "touch"
> is a Very Slow way to make files?  That... ???
> 
> Something like the find incantation of another post is the easy way:
> 
>   find . -type f -name 'myfile\*.txt' | ls -t | sed 1q
> 
> That will require significant modification if the file line blows the
> command line argument length limit (no, xargs is _not_ your friend for
> this particular tasks - exercise for the reader to figure out why).
> 

Point... just that the OP never stated that the files were in 
exactly one dir and that duplicate file names were  or were not possible.
Yes close timestamps are also an issue (see stat).


-- 
	T o m  M i t cs h e l l 
	Found me a new hat, now what?

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines

[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux