I have below command which output the result as newlines in every key press. I don't want it to output to file as new lines instead I want it to send it to file without linefeeds.
stdbuf -o0 xinput test 11 >out
Is it possible?
Try add echo -n
stdbuf -o0 xinput test 11 | xargs echo -n > out
Update
As i understand from your comment, you want not just remove linefeed, but also output log on every keypress using xinput.
First check all input devices:
c0rp@c0rp:~$ xinput --list
This is a list of all available input devices
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ ETPS/2 Elantech Touchpad id=13 [slave pointer (2)]
⎜ ↳ RAPOO RAPOO 2.4G Wireless Device id=10 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Video Bus id=6 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]
↳ Power Button id=8 [slave keyboard (3)]
↳ Sleep Button id=9 [slave keyboard (3)]
↳ Asus WMI hotkeys id=11 [slave keyboard (3)]
↳ AT Translated Set 2 keyboard id=12 [slave keyboard (3)]
↳ RAPOO RAPOO 2.4G Wireless Device id=14 [slave keyboard (3)]
↳ USB2.0 HD UVC WebCam id=15 [slave keyboard (3)]
Now if you want to test device, use test
key, and as parameter use id from second column.
For example, i use wireless keyboard, id=14:
xinput --test 14
Here is output:
key press 42
key press 43
key release 43
key release 42
key press 44
And finaly what you want is...
Sorry, on this step i realize that xinput cannot redirect stdout or stderr, it just buffered. Proof link.
So the only way to do what you want using xinput
is:
Write xinput to a file xinput test 11 > out
, then substitute all newlines using tr
tr -d '\n' < yourfile.txt
or if it doesn't work use same for DOS/Windows line endings
tr -d "\n\r" < yourfile.txt
You should be able to either pipe it though tr
or run tr
on the final file. You can either replace the new lines with spaces
tr '\n' ' '
Or delete them all together
tr -d '\n'
For example:
stdbuf -o0 xinput test 11 | tr -d '\n' >out
stdbuf -o0 xinput test 11 >out
outputs to file but not with this stdbuf -o0 xinput test 11 | tr -d '\n' >out
stdbuf -o0 xinput test 11
, output nothing for me. I though you know what you are doing.