I have this input file:
...
https://long-url/something?value1=999&something=xyz?value2=555
https://long-url/something?value1=534&something=xyz?value2=2312
https://long-url/something?value1=534&something=xyz?value2=233
https://long-url/something?value1=534
...
I want to capture the value1 and value2 and output them as csv, and drops any lines that don't match:
...
999,555
534,2312
534,233
...
I have no problem on capturing the values, but I'm having issue removing any unwanted lines:
sed 's/.*categoryid=\([0-9]*\).*courseid=\([0-9]*\).*/\1,\2/g;/^[^0-9]\+/d' input-file
Basically, the /^[^0-9]\+/d
is not working as intended. I was thinking that it would remove any lines that don't start with any digit, but instead, it gave me:
999,555
534,2312
534,233
My sed version: sed (GNU sed) 4.7