I'm trying to match first letter, in this example "B", and second column "2". When match is found replace characters [38-41] with white spaces.
Here is the data I'm trying to modify:
A1234A123 1 2 12345.12345 1234.1234.112341234
B1234A123 2 2 12345.12345 1234.1234.112341234
A1234A123 2 2 12345.12345 1234.1234.112341234
I can match the conditions with awk using:
awk '/^B/ && $2=="2" {print}'
and I can modify the lines with sed using:
sed -r 's/^(.{37})(.{4})/\1 /'
I'm trying to find the lines in the file which contains the two conditions and then modify the characters, while still printing the entire line of lines that don't match. Can you combine the two commands in order to introduce some sort of if/then statement?
I've tried to combine the commands, but it edited all of the lines:
awk '/^B/ && $2=="2" {print}' ¦ sed -r 's/^(.{37})(.{4})/\1 /' data
Resulting data should look like this:
A1234A123 1 2 12345.12345 1234.1234.112341234
B1234A123 2 2 12345.12345 1234.1234.1 1234
A1234A123 2 2 12345.12345 1234.1234.112341234
Thanks in advance.