C
C
cyberlain2021-05-05 13:17:34
linux
cyberlain, 2021-05-05 13:17:34

How to find and replace the last two characters you are looking for on each line?

There is a csv file with a large number of rows like
Sennheiser;;60;;1;4044155246612;инфо1;инфо2;инфо3

It is required to merge the data from the last three columns into one. To do this, I need to find and replace the last two semicolons with a slash in each line (so that in the last column it turns out; info1 / info2 / info3). How to do it in one line?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir, 2021-05-05
@cyberlain

[email protected] ~ $cat /tmp/ttttt 
Sennheiser1;;60;;1;4044155246612;инфо1;инфо2;инфо3
Sennheiser2;;60;;1;4044155246612;инфо1;инфо2;инфо3
Sennheiser3;;60;;1;4044155246612;инфо1;инфо2;инфо3
[email protected] ~ $cat /tmp/ttttt |awk -F ';' '{print $1 ";" $2 ";" $3 ";" $4 ";" $5 ";" $6 ";" $7 "/" $8 "/" $9}'
Sennheiser1;;60;;1;4044155246612;инфо1/инфо2/инфо3
Sennheiser2;;60;;1;4044155246612;инфо1/инфо2/инфо3
Sennheiser3;;60;;1;4044155246612;инфо1/инфо2/инфо3
[email protected] ~ $

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question