I’m running an application (CoronaSDK Simulator) from the terminal that puts an insanely long timestamp in front of every line of output.
Is there a way to use something like sed to chop it off and instead output everything else as it comes in (i.e. without having to wait until the program ends)?
I’ve tried a couple of things, but have had no luck so far…
Here are some sample lines:
2013-02-14 12:39:49.028 Corona Simulator[40803:707] |timer created
2013-02-14 12:39:49.029 Corona Simulator[40803:707] __in deck.lua__
2013-02-14 12:39:49.030 Corona Simulator[40803:707] storyboard.roomData.layout=A1 (room.lua)
Which I want to look like this:
|timer created
__in deck.lua__
storyboard.roomData.layout=A1 (room.lua)
I have tried
coronasim ./ | sed 's/Corona Simulator//'
as a test, and
coronasim ./ | sed -e 's/^.* //'
as suggested below, and even
coronasim ./ > /dev/null
but nothing seems to change the output.
The solutions was this:
coronasim ./ 2>&1 | sed -e 's/^.*] //'
as per choroba’s suggestion below. Seems that the Corona SDK simulator sends output to stderr instead of stdout.
And for anyone else interested, created a simple bash script that runs the program in the current director in the simulator, stripping out the timestamps:
/Applications/CoronaSDK/Corona\ Simulator.app/Contents/MacOS/Corona\ Simulat
or ./ 2>&1 | sed -e 's/^.*] //'
Yes,
sedas a stream editor should be the right tool for the job. Just redirect the output of your application to it:You might encounter problems, though:
If the application writes to a standard error rahter than standard output, you have to redirect the stream with
myapp 2>&1 | sed -e …
It is possible that the application would buffer its output if it is not connected to a terminal. Unless there is a specific option to change the behaviour, you are out of luck in this case.