I am having json file containing multiple "t" in it, I want to remove these characters from json file as when I am trying to convert this json file into CSV, because of these characters my CSV output disturbing.
I have tried multiple times with trial and error methods.
sed -i 's/t//g' input.json
Then I tried;
sed -i 's/^t//g' input.json
And then;
sed -i 's~t~~g' input.json
But unable to remove this "t" character from input.json file.
2
Answers
Backslash is special in sed regular expressions. To match it literally, you need to escape it by preceding it by another backslash.
To remove the backslash and "t" from a file, you can use the sed command in Linux:
Maybe, it’s better to use a JSON parser like
jq
to modify JSON files instead of using sed:Note: You can use the
-i
option in both commands to edit the file in place.