5

search for string and add the second line below

view full story
linux-howto

http://www.unix.com – Hi there, i have an /etc/hosts file that is organised in sections, like this Code: # # Oracle Servers # 1.1.1.1  boxa 2.2.2.2  boxb 9.9.9.9  boxj # # Prod Sybase Servers # 6.6.6.6  boxt 4.4.4.4 boxz I am just trying to write a line of code that will ill be able to pass the comment block name without the prepended hash and space (e.g. just ' Prod Sybase Servers') and it would add the new host entry at the top of the block under the last comment hash Ive managed to put together a little awk line that will take a string to search in the first column ($1 (HowTos)