Output from script:
[S\_M\_F\_ING\_MTG\_COM\_CUSTOMER_EXTRACT]
$InputFile_Borrower=CMTSLST\EDW_COMMERCIAL_MTGE_BORROWER_dat.lst
$InputFile_Customer=CMTSLST\EDW_COMMERCIAL_MTGE_CUSTOMER_dat.lst
$OuputFile_BorrowerNoGridID=CMTS$OutputFile_BorrowerDup=CMTS
And here's the simple sample script to read/output the input file:
cat abc.txt | while read -r line
do
echo $line
done
The read "-r" option is suppose to treat the input data as raw, but I think the script is trying to interpret the line $OuputFile_BorrowerNoGridID=CMTS\cm_borrower_exception_no_grid_id.out
.... as \c special character.
I've read that single quotes can preserve the input data as is with no interpretation but I'm not sure how to implement it in my above script.
Thank you Methyl......your solution works great!!!!
Is there a way to store the value in a variable? I tried the following but it's not working as expected:
cat abc.txt | while read -r line
do
var1=`print -r "${line}"`
echo "$var1"
done
The reason that I want to store the value in a variable is because I have some logic in my script and want to make reference use of a variable var1 in a number of places.
This required solution is work-related and script is doing some logic verification based on input file and it's not a matter of just copying (cp) the input file.
I've only shown a simplified sample script in order to get a solution.
One observation. Is it safe to assume that the file names in your variables are for a Windows or Netware server? Filenames containing a backslash character "\" will give you grief in a unix filesystem and as you have found require special treatment in shell variables. The unix delimiter between a directory name and a file name is of course a solidus character "/".
The text in bold-faced-red is making reference to a subdirectory on our Unix server.
From what I understand, the input data cannot be stored in a variable called var1? I wanted to store the input data in a variable so that I can compare it to some constant value (while also preserving the input raw data).
For ex: Logic in my script is as follows:
if $var1 = "ABC" then
output_line = "First level"
else
if $var1 = "CDE" then
output_line = "Second level"
else
output_line = "Third level"
fi
fi
As you can see, it's not just reading the input and printing it out - I need to process the input data and comparing it.