C
C
cyberlain2021-03-30 17:11:10
linux
cyberlain, 2021-03-30 17:11:10

How to remove multiple given characters from all strings?

How to remove one character is known.

sed -i 's/\;//g' init.txt; # удаление всех точек с запятой
sed -i 's/\,//g' init.txt; # запятых
sed -i 's/\"//g' init.txt; # и кавычек
sed -i 's/\&//g' init.txt; # амперсанда

the question is how to remove them in one line? What regular expression should be written?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vitsliputsli, 2021-03-30
@cyberlain

If via sed:
sed -i 's/[;,"&]//g' init.txt;

A
Alexander, 2021-03-30
@shabelski89

sed -i 's/\;//g; s/\,//g' init.txt;

K
ky0, 2021-03-30
@ky0

What regular expression should be written?

Appropriate for what you want it to do.
https://regex101.com/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question