Reputation
Top tag
Next privilege 2,000 Rep.
Edit questions and answers
Badges
1 7 20
Newest
 Enthusiast
Impact
~66k people reached

4h
revised Linux LUKS encrypt and cloning machines
typo in title
4h
suggested approved edit on Linux LUKS encrypt and cloning machines
4h
answered Linux LUKS encrypt and cloning machines
1d
comment Is it possible, with `sed` or otherwise, to apply a regex transform to an input stream that may not contain newlines?
the sol1_5 works well. I have just modified my Ruby script to insert a newline if it blocks. Again, probably not the best code in the world but it works and the data stream isn't so great that writing a character at a time really bothers me. One difference I note is that my code passes anything through, inserting newlines before any delimiters in the stream, whereas yours drops lines without delimiters. Not a major issue as the stream is compliant with that but a minor difference nonetheless
1d
revised Is it possible, with `sed` or otherwise, to apply a regex transform to an input stream that may not contain newlines?
added 54 characters in body
1d
revised Is it possible, with `sed` or otherwise, to apply a regex transform to an input stream that may not contain newlines?
added updated example with non-blocking reads
1d
accepted Is it possible, with `sed` or otherwise, to apply a regex transform to an input stream that may not contain newlines?
1d
comment Is it possible, with `sed` or otherwise, to apply a regex transform to an input stream that may not contain newlines?
Well it isn't my Ruby program. I've done some tests and the downstream pipe (systemd-cat in my case) buffers until it gets a newline. If I just run the pipe into my Ruby program from a terminal than I get all the output immediately. To my Ruby program the input is one long line. I wonder if I could detect the stream blocking and send a newline if the last character wasn't...
1d
comment Is it possible, with `sed` or otherwise, to apply a regex transform to an input stream that may not contain newlines?
just noticed I have the same issue. I'm looking to see if I can fix it...
1d
comment Is it possible, with `sed` or otherwise, to apply a regex transform to an input stream that may not contain newlines?
I thought your sol2 was the way to go for a second there, but it still buffers the end of line as you said in your answer. I have some timings for you (input yields 93 lines after processing): your original solution: real0.008s user0s sys0.003s; sol1: r0.022s u0.003s s 0.020s; sol2: r0.026s u0.003s s0.003s sol2: 0.022s and my Ruby script: r0.045s u0.033s s0.010s.
1d
awarded  Enthusiast
2d
revised Is it possible to add a process to the job list in bash (e.g. to reverse “disown”)?
fix typo
2d
accepted Can socat be started directly by systemd?
2d
comment Is it possible, with `sed` or otherwise, to apply a regex transform to an input stream that may not contain newlines?
@PSkocik you're right. it does work with -n. My prompt clears the current line before displaying and that hid it.
2d
comment Is it possible, with `sed` or otherwise, to apply a regex transform to an input stream that may not contain newlines?
PSkocik actually I stand corrected by @Gilles. Sed (at least my GNU v4.2.2) does not output the last line if it hasn't got a newline terminator.
2d
comment Is it possible, with `sed` or otherwise, to apply a regex transform to an input stream that may not contain newlines?
That's interesting. On my GNU sed 4.2.2, if I do echo -n "abc" > file ; sed 's/a/b/' file I get nothing - I never knew that! If I remove the -n I get bbc as you say. But we're digressing from the original question. Can you link to the definition of a text file ?
2d
comment Is it possible, with `sed` or otherwise, to apply a regex transform to an input stream that may not contain newlines?
See this sample data and my notes. It does work with an input file but not for some reason across a socat pipe. I think am going to go with my ruby answer on this one. I will do some timings for you though, I just need to collect some data first.
2d
answered Receiving Syslog messages with a systemd Arch Linux
2d
revised Is it possible, with `sed` or otherwise, to apply a regex transform to an input stream that may not contain newlines?
fix typo
2d
comment Is it possible, with `sed` or otherwise, to apply a regex transform to an input stream that may not contain newlines?
@PSkocik - that works because there is an EOF at the end of the string and that causes sed to flush its buffer. That doesn't apply to a continuous stream.