Re: [OT] Awk question

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

 



On Wed, Aug 20, 2008 at 11:03:58AM +0100, Dan Track wrote:
> Guys,
> 
> Just wondering if you could lend me a little hand. Basically I want to
> rename a file from log.1 log.2 etc to log.10.36.34. The time stamp
> (ignore the date) should be the last written time, so far I've got to
> this stage:
> 
> stat log | sed  -n '/Modify:/p' | awk -F ' ' '{print $3}'
> 
> so I get :
> 11:01:09.000000000
> 
> How can I get rid of the leading 0'swithout having to pipe the output
> to anotehr awk statement, is it possible to do this withing the
> current awk statement?
> 
Probably, yes, look at the substr() function.

You don't need the sed in the pipe either I don't think, you could do
this with the pattern matching capabilities of awk, e.g. (not tested) :-

    stat log | awk -F ' ' '/Modify:/ {print $3}'

(N.B. I haven't done the substr() bit)

-- 
Chris Green

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
[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