SED replace the same case for something

0

I'm trying to replace occurrences of "strings that appear in the document" by another value in the case '' nothing;

I have the following code snippet in shell script

mkdir NOVO
for script in *.sql
do 
    sed '/from/ s/fev_\|jan_//g' $script >> NOVO/$script
done

What happens is that it will only replace the "fev_" and "jan_" occurrences that are tiny, but there are major occurrences like "FEV_" and even mesno "Feb" how can I automate this script to capture all these occurrences?

    
asked by anonymous 27.06.2018 / 04:01

1 answer

1

The sed replacement command has an "I" flag that is used to make the regex case-insensitive . Do man of thirst:

I i The I modifier to regular-expression matching is a GNU extension which makes sed match regexp in a case-insensitive manner.

So, you can change your command to:

sed '/from/ s/fev_\|jan_//Ig' $script >> NOVO/$script

If you want to test:

cat teste.txt linha Linha LINHA lINHA NADA

sed 's/linha/alterado/g' teste.txt alterado Linha LINHA lINHA NADA

sed 's/linha/alterado/Ig' teste.txt alterado alterado alterado alterado NADA

References:

link link

    
27.06.2018 / 16:25