Hi,
In ksh (hp-ux), we are concatenating several files before sending them along to another system.
Each line in the file is supposed to end with a cr/lf (\015\012). However we have an occasional file where the cr/lf is missing from the last line of the file. This causes the first line in the next file to be appended to that line, which is then ultimately truncated.
I would like to modify the script to concatenate the characters to the end of the file only if they are missing,
prior to the concatenation step.
I have a script where I compare the results of tail to the contents of a file that contains the correct characters, but this seems rather indirect. Is there a way to directly test for this? What is the syntax?
Here is the code that I have been playing with:
testfile="XYZ"
testfile1="$testfile"1
var=`tail -c -2 $testfile`
crlf=`tail -c -2 CRLFFILE`
if [[ $var = $crlf ]]
then
echo "$var = $crlf"
else
echo "$var not = $crlf"
cat $testfile CRLFFILE > $testfile1
fi
exit
Thanks,
Joan
In ksh (hp-ux), we are concatenating several files before sending them along to another system.
Each line in the file is supposed to end with a cr/lf (\015\012). However we have an occasional file where the cr/lf is missing from the last line of the file. This causes the first line in the next file to be appended to that line, which is then ultimately truncated.
I would like to modify the script to concatenate the characters to the end of the file only if they are missing,
prior to the concatenation step.
I have a script where I compare the results of tail to the contents of a file that contains the correct characters, but this seems rather indirect. Is there a way to directly test for this? What is the syntax?
Here is the code that I have been playing with:
testfile="XYZ"
testfile1="$testfile"1
var=`tail -c -2 $testfile`
crlf=`tail -c -2 CRLFFILE`
if [[ $var = $crlf ]]
then
echo "$var = $crlf"
else
echo "$var not = $crlf"
cat $testfile CRLFFILE > $testfile1
fi
exit
Thanks,
Joan