C
C
cyberlain2021-04-14 13:14:57
linux
cyberlain, 2021-04-14 13:14:57

How to find strings with a certain substring and replace them with another substring?

It is necessary to iterate over the csv file and (for example) if it contains a line containing ' Accustic Arts' , then replace xxxx located in this line with yyyy

'xxxx';'41680';'Tart_200005338';'Accustic Arts POWER-ES MK2 silver';'Accustic Arts';'20';'300960.00';'N'


How to write a one line command for such a simple replacement?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sand, 2021-04-14
@cyberlain

sed -i '/Accustic\sArts/s/xxxx/yyyy/' file.csv

X
xibir, 2021-04-14
@xibir

Something like

sed -ri 's/(.*)xxxx(.*Accustic Arts.*)/\1yyyy\2/' file.csv

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question