How to remove quotes from text

tail +tr:

tail -n +2 file | tr -d \"

tail -n+2 prints the file starting from line two to the end. tr -d \" deletes all double quotes.


This should work:

sed -i '1d;s/"//g' filename

Explanation:

  • -i will modify the file in place
  • 1d will remove the first line
  • s/"//g will remove every " in the file

You can first try without -i and the output will be printed to stdout.


Solving the issue as it is presented in the title, i.e. removing double quotes from the first space-delimited column, only:

awk -F ' ' '{ gsub("\"", "", $1) }; NR > 1' file

This uses the gsub() command to remove all double quotes from the first field on each line. The NR > 1 at the end makes sure that the first line is not printed.

To remove the double quotes from the first field, but only if they appear as the first and last character of the field:

awk -F ' ' '$1 ~ /^".*"$/ { $1 = substr($1, 2, length($1) - 2) }; NR > 1' file

This uses a regular expression, ^".*"$ to detect whether there are double quotes at the start and end of the first field, and if there are, a block that extracts the internal part of the string with substr() is triggered. Any internal double quotes in the field are retained.