cat group.txt

        Flags: E,3
        "Jason" "O"
        "Kim" "T"
        "Eric" "G"
        "Jenny" "B"

        "Smith" "O"
        "Turner" "T"

        Flags: E,3
        "Hulk" "O"
        "Ironman" "T"
        "Loganoll" "G"

I would like to remove the extra double-quote(") from this file using sed (or any other). Notice BASEBALL and SOCCER have extra double-quote (") in the front of the string.

I tried to use

sed 's/^\"\"[a-zA-Z0-9]/\"\$/g' group.txt >> group.txt.dqremoved

but it doesn't do anything.


If you just want to replace two leading double quotes with one, you don't need anything more complicated than

sed 's/^""/"/' group.txt > group.txt.dqremoved

If you want to remove only the first character per line you could use

cut -c 2- file
  • This would remove the " before TENNIS too, and move everything left by two character positions. – Kusalananda Oct 21 '17 at 9:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.