Re: OT: replace a timestamp across multiple files

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

 



Once upon a time, Mike Wright <nobody@xxxxxxxxxxxxxxxxxxxx> said:
> I have a set of dns zone text files in "bind" format.  On the fourth
> line there is a 10 digit timestamp (ignoring white space, the first
> field).  There is no way to predetermine the value so search and
> replace by value is a no go and seems to require some positional
> approach such as "line 4, first 10 digit field".
> 
> What is the easiest way to replace each of them with the same value,
> $(date +%s) ?

The BIND zone file format is very unfriendly for easy script changes
unfortunately.

The easiest way (without a full parser) to do it is to find the existing
value by generating a well-known format of the file; for example,
named-checkzone (from bind-utils) can dump a "canonical" format of a
zone, which you can then grep out the SOA record and get the current
serial number.  Then you can do the basic search-and-replace approach,
although that can be a problem too (for example, 1 is a valid serial,
and you don't want to s/1/1234/ and replace all instances of "1").

-- 
Chris Adams <linux@xxxxxxxxxxx>
_______________________________________________
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/users@xxxxxxxxxxxxxxxxxxxxxxx



[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux