Could you please check once if your Input_file is having carriage returns in it? By doing cat -v Input_file if yes then kindly remove them from following command.
You have shown us that you have two input files with <carriage-return><new-line> line separators and no final line terminators (i.e., DOS text file format).
You have shown us several outputs that you have gotten from what you originally tried and form what others have suggested and you have told us that none of them are what you want. But, from your description and from your examples, I don't know whether you're trying to get all lines from each input file combined into single lines (one for each input file) in the output, all input lines from all files combined into a single output line (sequentially or pairwise), pairs of lines (one from each input file) combined into output lines, or something else.
Please show us the output you are hoping to get from your sample input files and tell us whether you want that output to be in DOS text file format (like your input files) or in standard UNIX text file format (i.e. <new-line> line terminators on every line with no <carriage-return> characters).
Thanks Don Cragun,
My objective is to have a single column data i.e. <new-line> line terminators on every line with no <carriage-return> as follow:
file1.txt:
Hmmm - repeating your unmodified problem description again doesn't really help, esp. when the error seems to have been tracked down by Scrutinizer - the (first?) file doesn't have the necessary line terminator on the last line. You'll have to repair that, esp. as his proposal doesn't work on your system. What would be the result of
You can use the following to directly process DOS format text files without manually stripping out the <carriage-return> characters from your input files...
Create a file named merge containing:
for file in "$@"
do tr -d '\r' "$file"
echo
done
Then you can issue the command:
sh merge file1.txt file2.txt > file3.txt
to get what you want as long as the file pathnames you pass to merge as operands are DOS format text files.
The file1.txt and file2.txt are sample file pathname operands gleaned from post #1 in this thread. This script will work with one or more file pathname operands.
Please don't forget the requestor is using Win 7 Pr., probably with a cygwin or busybox setup, both with a (limited?) set of not-necessarily-*nix-compatible tools. I'm not sure that s/he will really benefit from a pure *nix result file without \r line terminators on the Win 7 system.
I was well aware of the situation but he did stress that he wanted it in UNIX format in an earlier post.
Good point though, but it is just as easy to put '\r\n's back if that becomes a necessity.
My Cygwin crashed and I have to re-install it so I couldn't test the recommendations. I have tested the 'cat' on a windows 10 OS and it works fine. So, the problem is with my computer though am not sure what could be wrong while such a simple command to fail. I decided to move my data to another system for the operation. Thanks