janga
June 8th, 2007, 10:27 PM
Hi guys,
I am just about to learn sed, the stream editor.
Now I hav a problem that i cannot resolve with the help of google.
Basically, I want to format the output of amulecmd into something more readable.
This is my current script:
#!/bin/sh
amulecmd -c "show dl" | grep Herunterladen | sed -e 's/^ .\{35\}//g' -e 's/Herunterladen //g' -e MISSING CODE | grep --color '\[[0-9]\{1,3\},[0-9]\{1,2\}%\]'The output looks something like this (the last grep command is just to colorize the %):
Alpha Centauri - 2x04 - Wie Ist Die Milchstraße Aufgebaut.mpg [73,2%] 1/19 - 7,19 kB/s
Alpha Centauri - 2x07 - Gibt Es Schnapps Im All.mpg [64,8%] 1/13 - 72 bytes/secNow, you might not see it, but there is a TAB between .mpg and [XX,X%]. What I want to do is to cut the lines into 2 parts around the TAB and switch them. It should look like this:
[73,2%] 1/19 - 7,19 kB/s - Alpha Centauri - 2x04 - Wie Ist Die Milchstraße Aufgebaut.mpg
[64,8%] 1/13 - 72 bytes/sec - Alpha Centauri - 2x07 - Gibt Es Schnapps Im All.mpgAny Ideas?
I am just about to learn sed, the stream editor.
Now I hav a problem that i cannot resolve with the help of google.
Basically, I want to format the output of amulecmd into something more readable.
This is my current script:
#!/bin/sh
amulecmd -c "show dl" | grep Herunterladen | sed -e 's/^ .\{35\}//g' -e 's/Herunterladen //g' -e MISSING CODE | grep --color '\[[0-9]\{1,3\},[0-9]\{1,2\}%\]'The output looks something like this (the last grep command is just to colorize the %):
Alpha Centauri - 2x04 - Wie Ist Die Milchstraße Aufgebaut.mpg [73,2%] 1/19 - 7,19 kB/s
Alpha Centauri - 2x07 - Gibt Es Schnapps Im All.mpg [64,8%] 1/13 - 72 bytes/secNow, you might not see it, but there is a TAB between .mpg and [XX,X%]. What I want to do is to cut the lines into 2 parts around the TAB and switch them. It should look like this:
[73,2%] 1/19 - 7,19 kB/s - Alpha Centauri - 2x04 - Wie Ist Die Milchstraße Aufgebaut.mpg
[64,8%] 1/13 - 72 bytes/sec - Alpha Centauri - 2x07 - Gibt Es Schnapps Im All.mpgAny Ideas?