Question

Regex match every char but the following
This didn't help me.

I'm trying to match momentaneousVehicleSpeedKmph= followed by anything but 9 in a gz file.

These don't match:

$zgrep "momentaneousVehicleSpeedKmph=\[\^9\]" file.gz
$zgrep "momentaneousVehicleSpeedKmph=\(\^9\)" file.gz
$zgrep "momentaneousVehicleSpeedKmph=\^\[9\]" file.gz
$zgrep "momentaneousVehicleSpeedKmph=\^\(9\)" file.gz

This does:

$zgrep "momentaneousVehicleSpeedKmph=\(9\)" file.gz

I now there're lines in the file containing momentaneousVehicleSpeedKmph=89.

Was it helpful?

Solution

simply try

$zgrep "momentaneousVehicleSpeedKmph=[^9]" file.gz

if you don't want to match the single 9.

/edit

If you also need speeds with 2 digits and more, try:

momentaneousVehicleSpeedKmph=([0-8]|[0-9]{2,})\b

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top