Hi all,

As the name suggests, sriptingnoob by name scriptingnoob by nature!

I really need some advice, as I am loosing what little hair I have left.

I have a file which contains lines similar to these




I want to write a script in linux that can be used to add new machines into the file using the next available number. I am happy with writing info into a file etc but I am struggling to work out how to find the next available number for the MACHINES. I want to try and keep with shell scripting rather than having to learn perl etc

Does anyone have any suggestions? I would be most grateful

Well, considering you will need to learning something in either case it might be worth your while to learn something directly suited to this type of behavior. For instance Ruby, Python, or Perl are all easier to use as a newcomer when parsing text; AWK and shell not so much (the AWK part is debatable).

Also, before providing any sample code, what do you mean by next available number? Is there a resource that gives these out? Should it be inferred from the file contents? Are you talking about the indexes or IP addresses? It would help if you clarified a bit.