How to remove quote character using awk

To remove quote characters using awk, you can use the gsub function, which stands for “global substitution“. Here’s an example of how to do it:

Let’s assume you have a file named input.txt with lines containing quotes, and you want to remove those quotes:

Contents of input.txt:

"Hello, World!"
"This is a quote."
"Another quote."

You can use the following awk command to remove the quote characters:

awk '{gsub("\"", ""); print}' input.txt > output.txt


  • awk is the command to invoke the awk utility.
  • gsub("\"", "") is used to globally substitute the double quote character " with an empty string "", effectively removing the quotes from each line.
  • print is used to print the modified line.
  • input.txt is the input file containing the lines with quotes.
  • output.txt is the file where the modified lines without quotes will be stored.

After running the awk command, the contents of output.txt will be:

Hello, World!
This is a quote.
Another quote.

As you can see, the quote characters have been removed from the lines in the output file.

Leave a Comment