Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 117
  • Last Modified:

how to remove double quotes from a file

How would I remove double quotes from a file

For example:
,XXXX,BBBBBB,"CCCCC",444444,"999999"


Thanks in advance
0
bje
Asked:
bje
  • 4
  • 4
3 Solutions
 
woolmilkporcCommented:
sed -i.bak 's/"//g' filename

The above will create a backup file "filename.bak" and change the original file "filename" "in place".
0
 
woolmilkporcCommented:
To change just a single string (as the example in your question) just do

echo ',XXXX,BBBBBB,"CCCCC",444444,"999999"' | tr -d '"'

'"' after "-d" is: "single_quote double_quote single_quote" (without any intervening spaces).

With variables:

STRING=',XXXX,BBBBBB,"CCCCC",444444,"999999"'
NEWSTRING=$(echo $STRING | tr -d '"')
or even
STRING=$(echo $STRING | tr -d '"')
0
 
NVITCommented:
RmvQuotes.txt:
XXXX,BBBBBB,"CCCCC",444444,"999999"
XXXX,"BBBBBB","EE",444444,"XX"

Open in new window


RmvQuotes.bat:
@echo off
for /f "tokens=*" %%a in (RmvQuotes.txt) do (call :DoIt %%a %%b %%c %%d %%e)
goto :EOF

:DoIt
echo %~1,%~2,%~3,%~4,%~5

Open in new window

0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
bjeAuthor Commented:
Thanks for the solutions.

Once the double quotes are removed will need to look for at the beginning of the line and look for  ,H and when found replace the  , with a TR

Have this,
sed 's/^,H/ /^,H\TR/g  < filename

How do you combine them?

Thanks
0
 
woolmilkporcCommented:
Do you mean the literal string "TR" or something else, like a control character?

Replace "," with "TR" and combine this with the other command:

sed -i.bak 's/"//g;s/^,H/TRH/' filename

",H" will become "TRH" this way. Is it that what you desire?
0
 
bjeAuthor Commented:
yes. each row that matches would start wtih TRH.

Thanks
0
 
woolmilkporcCommented:
So use this solution (already posted above, but here it is again):

sed -i.bak 's/"//g;s/^,H/TRH/' filename
0
 
bjeAuthor Commented:
I am trying to mark the two open questions complete, however it is not saving this information.  how to I close these tickets.  I have marked the solution accepted and award points and clicked on submit.

Thanks
0
 
bjeAuthor Commented:
Thanks
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now