Hey - my first post here, and I'm a total SED newb. I've looked around for previous help on this, but have so far been unsuccessful.
I have a program (AMStracker for OS X) that outputs data in the terminal. Output is in this form:
.
.
.
3 0 -75
3 0 -76
3 0 -77
5 0 -75
3 0 -76
3 0 -75
5 0 -76
6 0 -76
2 0 -75
2 0 -75
5 0 -76
3 0 -76
5 0 -77
3 0 -75
3 0 -77
.
.
.
column ranges are from -255 to +255, but that should not matter here...
All I want to do is pipe AMStracker output into SED so that the final output looks like this:
.
.
.
3 0 -75;
3 0 -76;
3 0 -77;
5 0 -75;
3 0 -76;
3 0 -75;
5 0 -76;
.
.
.
Basically I want to append a ';' to each line.
I've been fooling around and so far have this:
./amstracker -u 0.05 -s | sed a\\n";"
Which does not work. I get errors I don't undestand:
--> sed: 1: "a\n;": extra characters after \ at the end of a command
Can anyone offer some help? I woudl assume that something liek this should be rather simple for SED. Should I be using another tool?
I found the answer on this forum... sorry for the repeat.
Here is the link to the post that helps:
http://www.unix.com/showthread.php?t=21191
Actually this implementation does not work for me. Not entirely at least.
I do get the output I am looking for with this, ie.:
.
.
.
10 0 8;
10 0 8;
10 0 8;
10 0 7;
10 0 8;
.
.
.
However, it strips either the carriage return or the new line, or both, which I need to retain. For example:
running
/amstracker -u 0.05 -s | sed 's/$/;/'
gives the output seen above, but if I try running
/amstracker -u 0.05 -s | sed 's/$/;/' | sed 's/$/;/'
Which I should be able to do (it would just add another ';' to each line right?)
In reality I see nothing in the terminal when I run this.
I'm trying to add a newline or carriage return after the ;, but I'm not sure how...
Again, I'm a SED newb.
/amstracker -u 0.05 -s | sed 's/.*/&;/'
Thanx, but it still does not work for me.
I'll be more specific:
After the ./amstracker -u 0.05 -s | sed 's/.*/&;/'
I want to pipe it into netcat (nc) so I can send it over the network, or to another port on the same machine. I know it's a weird setup, but it's a hack that will save me a lot of work in the future.
When I do:
./amstracker -u 0.05 -s | sed 's/.*/&;/' | nc 127.0.0.1 5001
it connects to an instance of: nc -l -p 5001 (on 127.0.0.1)
but no data goes thorough...
I'm cleary an idiot.
Any more suggestions?