0

I have a ksh script, where I am trying to read from file in a loop and append certain values to each line in the file. It is not working.

Below is the code: Code snippet:

input="$v_error_request_file_report"
while IFS= read -r line
do
  echo "$line"
  x="L"$line".out"
  echo "$x"

done < "$input"

Contents of input file:

9359677

9359678

expected output:

9359677

L9359677.out

9359678

L9359678.out

Output generated:

9359677

.out9677

9359678

.out9678

  • 4
    Possibly your input file has DOS-style (CRLF) line endings – steeldriver Jun 2 at 21:50
  • For debugging, add echo "$line" | od -bc – waltinator Jun 3 at 2:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.