Artificial intelligent assistant

How to trim space between two delimiters - Unix In a file we have key and value pairs separated by |, my request is to remove space in key pair as shown in Input and Output. Example: UTC Time Offset -> UTCTimeOffset I have tried different sed and awk commands but unable to get the right commands Input: LogID = AMQ11111.0.FDC|Date/Time = Wed April 14 2021 03:19:43 EET|UTC Time = 1618334334.03|UTC Time Offset = 660 (EFT)| Output: LogID = AMQ11111.0.FDC|Date/Time = Wed April 14 2021 03:19:43 EET|UTCTime = 1618334334.03|UTCTimeOffset = 660 (EFT)|

Assuming that no key or value contains embedded `|` or `=` characters:


awk 'BEGIN { ORS = RS = "|"; OFS = FS = " =" }{ gsub(" ", "", $1) }; NF > 1' file


This treats the input as a set of `|`-delimited records. Each record uses ` =` (space+`=`) as the field delimiter.

For each record, the spaces in the first field (your keys) are deleted using `gsub()`. If the current record has more than a single field, it is then printed (this is tested to avoid outputting an empty record at the end).

There is no newline at the end of the output.

I'm unfortunately unable to test this on AIX, but I don't think it uses any non-standard `awk` features.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy e57a6f20e195551b95992f8ada7b14cb