Manipulate text file to allow import to excel
Have managed to create a simple script to poll the various printers we have at our company for a page count via SNMP. At the moment the script echos the printer name to a text file and then the snmp output is appended to the next line. In my rush I thought by using sed to add a comma to the end of each line would mean it would import in to excel nicely. So rather than having:
Printer 1, 45536,
Printer 2, 28765,
Is there a way to do this easily via sed? Or is there a way to get the command line to add the echo and the command output on to the same line of the text file?
currently the script looks like this:
You can try adding -n option to echo.
or to fix using sed
If I have more time later I'm try and find a better solution.
More complex than sed, but a solution would be to use a counter and the modulo of the current iteration to add ,\n
something like this:
Thanks for that. Your command IW2B works like a charm. unfortunately not all my snmp commands have been answered so there is no output in the text file. this makes all the lines get muddled up! Think I am going to have to go and learn some if - for -else scripting and try and fiddle a null input for no response etc. knew it would turn out more complicated then i thought it would be originally.
|All times are GMT -5. The time now is 06:15 PM.|