I'm trying to do some simple parsing of the output of the xinput
command in a shell script. What I am trying to do works perfectly on the commandline, but doesn't work in the script.
Here is my commandline:
xinput list | awk '/Name of my Device id[0-9]* \[slave pointer/'
The output of the previous command:
⎜ ↳ Name of my Device id=12 [slave pointer (2)]
When at the prompt, I input the tabs by hitting CTRL-V,TAB. When in the script, I input a line which reads:
xinput list | awk '/Name of my Device id[0-9]*/'
Which returns three lines of data. As soon as I add another tab, like so:
xinput list | awk '/Name of my Device id[0-9]* /'
I no longer get any output. I tried with both CTRL-V,TAB and just with TAB. I've also tried manually typing the whole script line from scratch in case there was a non-printable in there somewhere. Why is awk
able to deal with the first tab, but not the second? BTW, I've tried this with dash, bash, and zsh. The behavior is identical.
Thank you very much.
P.S. I forgot to mention my editor is vim.
P.P.S
xinput list | awk '/Name of my Device id[0-9]* \[slave pointer/' |
sed 'y/ \t/_$/'
outputs:
⎜___↳_Name_of_my_Device$id=12$[slave__pointer__(2)]