Re: Script help



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



Relevant Pages

  • Re: Script help
    ... | And if the question was to tinker with a set of files ... be too many files to fit on a single command line? ... That the script calls ... That will require significant modification if the file line blows the ...
    (Fedora)
  • Re: Windows Scripting - Timestamp, files, need help. :)
    ... I need to write a script in vbscript (I want to use ... checks to see what the timestamps are. ... and formatting it YYYYMMDDHHMM ... formatting each item in the array into the format YYYYMMDDHHMM ...
    (microsoft.public.scripting.vbscript)
  • Multiple file transfers using ftp
    ... FTP server that are in mulitple directories with a single command or ... *.txt from the parent directory the entire directory structure is ... grow and I will have to change the script to add the new directories. ...
    (comp.sys.ibm.as400.misc)
  • subroutine references
    ... I'm working on yet another exercise from Intermediate Perl. ... were modified between the two timestamps. ... $stop variables in the script at large. ... When I run the script I get these error messages: ...
    (perl.beginners)
  • Re: truncate all tables
    ... There is not a single command to do what you are asking. ... You can script it ... by selecting a string that builds your command by name from sysobjects where ... > Thanks for any help Mikey ...
    (microsoft.public.sqlserver.programming)