I have to delete a character at nth position in a big file. Vi
hangs for such a big file. I know there will be some simple command in sed
to do so. But, I find it difficult to understand sed
scripts and its expressions.
The file I have has content like:
{"query": "Lock and", "timestamp": "2012-12-28T00:00:00.045000+00:00", "productId": 322506},,{"query": "Velvet Crush", "timestamp": "2012-12-28T00:00:00.045000+00:00", "productId": 134363}
I have to delete that extra ,
which is 130405
th character in that file. How do I use sed to achieve this.
EDIT:
Now I wish to replace all aoocurances of double comma by a single one in-place. How can that be done?
sed -i 's/.//130405' FILE
This edits the file (
FILE
) in place (-i
), deleting any character (.
) at position130405
Without even worrying about exactly where the double comma is, and assuming you want to fix any double comma throughout the file:
If you have a version of
sed
that supports it, you cansed -i -e '...' file
to skip the redirections (butsed -i
still essentially does exactly the same thing, just with a temporary file).Why
sed
when you havecut
?