Skip to main content
question is about redirecting output, not input
Link

Cannot redirect inputoutput from sed

Source Link

Cannot redirect input from sed

I'm piping output from clock through sed to remove leading zeroes from numbers. It looks like this:

clock -sf 'S%A, %B %d. %I:%M %P' | sed 's/\b0\+\([0-9]\+\)/\1/g'

That works fine and produces the output I want.

However, when I try to redirect the output to a file, nothing is written to the file. The following does NOT work.

clock -sf 'S%A, %B %d. %I:%M %P' | sed 's/\b0\+\([0-9]\+\)/\1/g' > testfile

Nothing is written to testfile. What am I doing wrong?