I have to write a program to read data from files and then format into another file. However, I face a strange problem related to control character that I can't understand and solve.
The source file is compose of many lines with such format:
I suppose the problem being the "echo" statement. It is fed the content of the variable "$line" and interprets it. "\n" and "\t" in your example are control characters, though. "\n" is "newline", "\t" is tab.
Anyhow, your implementation isn't all too good anyway, because you use several commands and a pipeline to do what shell exansion could do too - at considerably less computing costs:
Change your code accordingly and it should not only work but run faster too.
An independent observation: DO NOT use backticks any more. They are deprecated and the shell only understands them for backward compatibility issues. Use the modern "$(...)" instead, which is a lot more flexible, can be nested, can be quoted, ...
Another hint: in case you write for Korn shell you might consider using file descriptors instead of redirection. Instead of:
I don't know if the code is incorrect or my working environment does not support shell expansion.
Anyway, using file descriptors instead of redirection is new to me.
Thanks to Lem, the lower one is what I want.
Thanks to bakunin and Lem for quick reply.