Hi,
I has the following command in the script. This command works fine if I execute on command prompt. If I run the script, this is not working as expected (deleting CR).
Assuming that your original file (which I shall call "filename") is a MSDOS text file with a carriage-return character in every record.
What is the output from this sequence of commands both from the command prompt and from a shell script. I'm assuming that your shell is not "csh" or "tcsh".
The "sed -n l" command just makes control codes visible.
filename="insert_the_name_of_your_original_file"
echo "Shell is:"
echo "${SHELL}"
echo "Original file"
head -1 "${filename}" | sed -n l
echo "Conversion 1"
head -1 "${filename}" |tr -d "\015" | sed -n l
echo "Conversion 2"
head -1 "${filename}" |tr -d '\015' | sed -n l
echo "Conversion 3"
head -1 "${filename}" |tr -d "\r" | sed -n l
Hi,
I see these DOS characters are not consistantly in all the lines. They appear in some lines only. As the below code will check for the CR in first line only, it could not help us in figuring out the issue.
I had seen some more characters like vt \(vertical tab - 0x0b\) etc.. as well.
I got the codes to remove all these DOS characters but it is working only sometimes.
I think we need to check for the previous command execution status before the next command executes in the script. Can someone explain more on this?