Actually I am usingsed -e s/Perro-A//g -i *-a.log to delete the string Perro-A from many files ending with *-a.log. But sometimes in the files I might not have Perro-A; I might have strings like Perro-B, Perro-C, Perro-14, Perro-X , Perro-DHFN, etc.I need to update the previous command to delete any string starting with Perro. How I can achieve this?
How to delete a variable string in file
command line;text processing;sed
Assuming you just wanted to delete all string starting with Perro, you can use:sed 's/Perro[^ ]*//g' *-a.logIf you want to edit the file in place, you can use -i option with sed, likesed -i sed 's/Perro[^ ]*//g' *-a.logUpdateIf you don't want to have multiple spaces, you can use:sed -i sed 's/Perro[^ ]*//g' *-a.log | tr -s  sample data,rahul@rahul: cat a.logFoo Perro-B Perro-C BarPerro-14 cmd  Perro-XPerro-DHFN abc xyzaBcD Perro-14rahul@rahul: sed 's/Perro[^ ]*//g' a.log | tr -s  Foo Bar cmd abc xyzaBcD