I want to find all instance of the minus sign followed by a one digit number in a line of text. The numbers are seperated by comma's but can also be at the end of the line
text.txt contains
hx,-7,u,-9,u,-8
(There is a newline at the end)
I'm running this command
egrep -o ',[\-][0-9][\n,]' text.txt
And get
,-7,
,-9,
But I want to get
,-7,
,-9,
,-8
Edit: Something like
hx,-7,u/-9,u,-8
Should still produce
,-7,
,-9,
,-8
And using
egrep -o ',[\-](1|2)?[0-9XY][\,$]' text.txt
Doesn't work for it