Skip to main content
added 2 characters in body
Source Link
user313992
user313992

That actually works on Linux:

echo hello | tee /dev/fd/0
hello
hello
hello
...

echo hello | gawk '!length{exit(0)} {print; print substr($0,2) >"/dev/fd/3"; fflush()}' 3>/dev/fd/0
hello
ello
llo
lo
o

That takes advantage of the fact that on Linux all pipes are actually named pipes (i.e. they can be openopened via a path). Using a regular named pipe, it will work on other Unix systems, too -- see this answer on Stackoverflow.

That actually works on Linux:

echo hello | tee /dev/fd/0
hello
hello
hello
...

echo hello | gawk '!length{exit(0)} {print; print substr($0,2) >"/dev/fd/3"; fflush()}' 3>/dev/fd/0
hello
ello
llo
lo
o

That takes advantage of the fact that on Linux all pipes are actually named pipes (i.e. they can be open via a path). Using a regular named pipe, it will work on other Unix systems, too -- see this answer on Stackoverflow.

That actually works on Linux:

echo hello | tee /dev/fd/0
hello
hello
hello
...

echo hello | gawk '!length{exit(0)} {print; print substr($0,2) >"/dev/fd/3"; fflush()}' 3>/dev/fd/0
hello
ello
llo
lo
o

That takes advantage of the fact that on Linux all pipes are actually named pipes (i.e. they can be opened via a path). Using a regular named pipe, it will work on other Unix systems, too -- see this answer on Stackoverflow.

simplify
Source Link
user313992
user313992

That actually works on Linux:

echo hello | tee /dev/fd/0
hello
hello
hello
...

echo hello | gawk '!length{exit(0)} {print; print substr($0,2) >"/dev/fd/3"; fflush()}' 3>/dev/fd/0
hello
ello
llo
lo
o

That takes advantage of the fact that on Linux all pipes are actually named pipes (i.e. they can be open via a path). Using a regular named pipe, it will work on other Unix systems, too -- see this answer on Stackoverflow.

That actually works on Linux:

echo hello | tee /dev/fd/0
hello
hello
hello
...

echo hello | gawk '!length{exit(0)} {print; print substr($0,2) >"/dev/fd/3"; fflush()}' 3>/dev/fd/0
hello
ello
llo
lo
o

That actually works on Linux:

echo hello | tee /dev/fd/0
hello
hello
hello
...

echo hello | gawk '!length{exit(0)} {print; print substr($0,2) >"/dev/fd/3"; fflush()}' 3>/dev/fd/0
hello
ello
llo
lo
o

That takes advantage of the fact that on Linux all pipes are actually named pipes (i.e. they can be open via a path). Using a regular named pipe, it will work on other Unix systems, too -- see this answer on Stackoverflow.

simplify
Source Link
user313992
user313992

That actually works on Linux:

echo hello | tee /dev/fd/0
hello
hello
hello
...

echo hello | gawk '{if(!length) print > "/dev/tty"; else {exit(0);} {print; print substr($0,2);fflush >"/dev/fd/3"; fflush()}' >3>/dev/fd/0
hello
ello
llo
lo
o

That actually works on Linux:

echo hello | tee /dev/fd/0
hello
hello
hello
...

echo hello | gawk '{if(length) print > "/dev/tty"; else exit(0); print substr($0,2);fflush()}' >/dev/fd/0
hello
ello
llo
lo
o

That actually works on Linux:

echo hello | tee /dev/fd/0
hello
hello
hello
...

echo hello | gawk '!length{exit(0)} {print; print substr($0,2) >"/dev/fd/3"; fflush()}' 3>/dev/fd/0
hello
ello
llo
lo
o
added 10 characters in body
Source Link
user313992
user313992
Loading
Source Link
user313992
user313992
Loading