Hi Guys,
I have a file which needs to be replaced with tab delimited
AA§Orgin Name§Mapping based on prod_usa§§§§
BB§Date§2019-08-11 23:30:01§§§§
I am trying below code
sed 's/[ -~ ^]/ /g' test.txt
Expected
AA|Orgin Name|Mapping based on prod_usa|||
BB|Date|2019-08-11 23:30:01||||
Could you just do this?:-
tr "§" "|" < inputfile > outputfile
I hope that this helps,
Robin
1 Like
you can get the required output through sed, try following command
sed -i 's/§/|/g' filename.txt
Hi rohit_shinez...
Your expected output shows 3 pipes at the end of the first line but the original has 4, is this correct?
rohit_shinez:
Hi Guys,
I have a file which needs to be replaced with tab delimited
AA§Orgin Name§Mapping based on prod_usa§§§§
BB§Date§2019-08-11 23:30:01§§§§
I am trying below code
sed 's/[ -~ ^]/ /g' test.txt
Expected
AA|Orgin Name|Mapping based on prod_usa|||
BB|Date|2019-08-11 23:30:01||||
Yes you are correct it should be ||||
, and is there a generic way to replace the special characters apart from §
, I mean if I get any other special character
gull04
August 14, 2019, 10:24am
6
Hi,
Yes, you can provide ranges of special characters in both sed
and tr
or you can work with one character at a time. All the information that you require should be in the man pages on your system, you can try man tr
this would be a good place to start.
Regards
Gull04
Neo
August 14, 2019, 10:27am
7
rohit_shinez,
You can't really expect to post a single small line of code and the expect people here to write every thing else for you.
Why don't you try again? Put your own work into the task and not change your original requirements and expect others to code it for you.
Please do some of your own work. TRY!
1 Like