Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove a specific character using awk or sed

I have a command output from which I want to remove the double quotes ".

Command:

strings -a libAddressDoctor5.so |\ grep EngineVersion |\ awk '{if(NR==2)print}' |\ awk '{print$2}' 

Output:

EngineVersion="5.2.5.624" 

I'd like to know how to remove unwanted characters with awk or sed.

like image 816
AabinGunz Avatar asked Nov 04 '11 11:11

AabinGunz


People also ask

How do you delete an awk character?

tr can be more concise for removing characters than sed or awk , especially when you want to remove multiple different characters from a string. -d stands for "delete".

How do I remove a specific character in Linux?

Remove Character from String Using trThe tr command (short for translate) is used to translate, squeeze, and delete characters from a string. You can also use tr to remove characters from a string. For demonstration purposes, we will use a sample string and then pipe it to the tr command.

Which is better sed or awk?

Both sed and awk allow processing streams of characters for tasks such as text transformation. The awk is more powerful and robust than sed. It is similar to a programming language.


1 Answers

Use sed's substitution: sed 's/"//g'

s/X/Y/ replaces X with Y.

g means all occurrences should be replaced, not just the first one.

like image 84
Piotr Praszmo Avatar answered Sep 22 '22 17:09

Piotr Praszmo