Pregunta

For this command xwininfo -id 0x8a00004 |grep "Absolute\|Width\|Height" I have this output

Absolute upper-left X:  44
Absolute upper-left Y:  53
Width: 999
Height: 698

by using a single sed command, I want it to become this:

nX=44
nY=53
nWidth=999
nHeight=698

My current code is this:

xwininfo -id 0x8a00004 |grep "Absolute\|Width\|Height" |sed -r 's".*([XY]):[[:blank:]]*(.*)"n\1=\2"'

I am aware that to match words with sed, I need to use \bWordToMatch\b on the expression, but I cannot find a way to put it where ([XY]) is on my command... I am aware also that to match "one OR other" word, I need to use \|, that I cant guess either..

¿Fue útil?

Solución

Try following sed

sed -r 's/.*(X|Y|Width|Height)\s*:\s*([0-9]+)/n\1=\2/'
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top