i can convert ticks to new lines using something like this:
tr '`' '\n' < filename
or
tr "\`" "\n" < filename
or vice versa
tr '\n' '`' < filename
or
tr "\n" "\`" < filename
however, this command seems to not work the same on every system. it works on ubuntu, and it works on redhat when run from the command line. but if run from a script, it gets rid of the '\n' and turns it to 'n', which then ends up replacing all letter "n's with '`'.
is there a different command i can use for this that will behave the same on every unix system? i've spent a couple of hours on this and nothing seems to work.
i just want to be able to translate all new lines to ticks and also be able to translate back to new lines in a reliable way.
I am not sure about all O.S(or on which you are currently), I had tested this following in Ubuntu and BASH and it worked fine for me. Could you please try following and let me know if this helps you. So let's say we have following Input_file.
cat Input_file
singh_is`_king1233
``is the input_file here.
test test test
test ` newline test `` again new line test
tr "$(printf "\x60\n")" "\n" < Input_file
Output will be as follows.
singh_is
_king1233
is the input_file here.
test test test
test
newline test
again new line test
Scrutinizer is right: tr works in both directions, on command line or in script, in Ubuntu or in FreeBSD. RedHat, being another linux flavour, shouldn't make any problems.
So - give us more info about the case when is doesn't work. How is the script run? What environment does it have? Any error messages?