Re: Script help

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

 



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.
> |
> | ls -t by itself may give you more than one filename per line.
> | Use ls -t1
> | that will assure you get only one file name output from head.
>
> Um, no. ls only multicolumns if you point its output to a terminal;
> the multicolumning was an innovation brought in BSD. Earlier lses
> always single columned, and continue to single column if sent to any
> non-terminal. Otherwise every script on the planet reading from ls
> would break.
>
> So, you do not need the "1" option in a pipeline, and never have.
>
> BTW, "sed 1q" is shorter than "head -1". I've never had much truck with
> "head"...

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


-- 
 NiftyFedora
 T o m M i t c h e l l

-- 
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]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux