I'm trying to sort my logs and found that single digit dates were cut incorrectly.
Now I want to either add a 0, or remove the extra space.
Prior to that, I wanted to see how to get the correct lines I want to edit.
A tail of last 3 lines:
$tail -3 testlog
Wed Feb 7 23:30:59 2018 daemon.info hostapd: wlan0: STA de:ad:be:ef:c0:fe WPA: group key handshake completed (RSN)
Wed Feb 7 23:40:59 2018 daemon.info hostapd: wlan0: STA de:ad:be:ef:c0:fe WPA: group key handshake completed (RSN)
Wed Feb 7 23:50:59 2018 daemon.info hostapd: wlan0: STA de:ad:be:ef:c0:fe WPA: group key handshake completed (RSN)
Now working my way to the script, I wrote this expecting to get the same result:
$ while read line; do if [ $(echo $line|cut -c7) == "b" ]; then echo $line; fi; done < testlog | tail -3
Wed Feb 7 23:30:59 2018 daemon.info hostapd: wlan0: STA de:ad:be:ef:c0:fe WPA: group key handshake completed (RSN)
Wed Feb 7 23:40:59 2018 daemon.info hostapd: wlan0: STA de:ad:be:ef:c0:fe WPA: group key handshake completed (RSN)
Wed Feb 7 23:50:59 2018 daemon.info hostapd: wlan0: STA de:ad:be:ef:c0:fe WPA: group key handshake completed (RSN)
But with this, the extra space before the 7 is removed. I did not expect this to happen. I'm not cutting it with my script, am I?
Thanks in advance!