2

Using sed for a direct stdin treatment of data, I expect that a line is treated after the enter. This is what happens when I test on CygWin or Linux but on my AIX, a second new line is needed to treat the line. I tried with the -u flag to avoid buffer latency without modification in behaviour. Is there an option or parameter to let the POSIX AIX sed work like on other OSs?

Example:

> sed -u '=;l;s/foo/bar/'
like my foo            (enter)
but not the lazy dog   (enter)
1                      (stdout)
like my foo$           (stdout)
like my bar            (stdout)
  • This is more than likely a quality of your line discipline than sed's deal. Use the l command to get a good look at what it sees as input. – mikeserv Jan 15 '15 at 9:37
  • adapt the post to show the stream. line seems ok, this is just the need of a second line like a buffer behaviour and only on my AIX (that use posix sed) – NeronLeVelu Jan 15 '15 at 9:54
  • Its not though - your terminal is doing something - icr nl? opost? what's definitely missing there is the \r. maybe prime it : echo | sed ... - /dev/tty. That wont get you the \r, but it might offset the line delay. This shouldn't be a problem in stty raw mode - but in that case you might have to specially handle \r \n. – mikeserv Jan 15 '15 at 10:05
  • \r appear on windows system, not unix by default. The - in sed ... - /dev is also not valid on my/a AIX/KSH (or bash) – NeronLeVelu Jan 15 '15 at 14:12
  • The \r appears on a windows system due to crlf line endings. But they will also appear on a linux system if you type one - like when you press return to a get a \newline. That's handled by your terminal driver's line discipline. If sed doesn't understand the - for stdin does it instead understand /dev/stdin or /dev/fd/0? – mikeserv Jan 15 '15 at 14:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.