I need to read temp.$i file content line by line through while loop but somehow the '\' do not appear in output.. Can someone guide how to read this exact content line by line in unix :
if [ -s "temp.$i" ]
then
cat temp.$i | head -1 # the file content appears fine
while read line1
do
echo "$line1" # the '\''s are being ignored in output
exit
done < temp.$i
fi
Output:
AM_DASHBOARD\MAIN\02RUN\RUNMISURE_E2E, sequence job # ok
AM_DASHBOARDMAIN02RUNRUNMISURE_E2E, sequence job #not ok
$1 is 'AM_DASHBOARD\MAIN\20RUN\RUNSURE_EEE, sequence job'
so jobname should be 'RUNSURE_EEE'
but I am getting output as 'AM_DASHBOARD\MAIN\20RUN\RUNSURE_EEE is jobname'
I have also tried:
$1 is 'AM_DASHBOARD\MAIN\20RUN\RUNSURE_EEE, sequence job'
so jobname should be 'RUNSURE_EEE'
but I am getting output as 'AM_DASHBOARD\MAIN\20RUN\RUNSURE_EEE is jobname'
Thanks. That got resolved. I noticed another issue with while loop
while read -r line1
do
echo $line1 > $wrkdir/datatemp
for \01 in $line1 , ^A is written in the output . \02 is ^B, \03 is ^C and so on
eg. abc\main\02Run is written as abc\main^BRun in the $wrkdir/datatemp file.
Can anyone explain that why or how to resolve?
if [ -s "$wrkdir/temp.$i" ]
then
while read -r line1
do
echo $line1 > $wrkdir/datatemp
done < $wrkdir/temp.$i
fi
content in temp.$i files is of following type :
A_DBOARD\MAIN\02RUN\RUNSURE_EEE
A_DBOARD\MAIN\03RUN\RUNSURE_EEE
....
Which is written in output file datatemp as
A_DBOARD\MAIN^BRUN\RUNSURE_EEE
A_DBOARD\MAIN^CRUN\RUNSURE_EEE
....
Thanks Ahamed, print -r worked fine for me.
uname -rs gave the version as
AIX 3
ygemici, the output of od -c is of the type :
0000220 P , s e r v e r j o b \n
0000240 C A M P A G N E 002 R U N \ R U N
0000260 E X T R C A M P A G N E , s e
0000300 q u e n c e j o b \n C
:
:
0000500 T \ E X T R A C T S S R C , s
0000520 e r v e r j o b \n C A M P
0000540 A G N E 002 R U N \ M R U N C A M
0000560 P A G N E , s e q u e n c e
Where ever there is 002 is where the 02 is replaced by ^B in the output file.
i think,this character of seqs is interpreted as "Start of text(^B)" from your shell.
it(probably your ksh) reads "\ and 02" and "02" is equal "002" in octal.
so "002" chars is now like ^B (STX). and there is a backslash in front of its.
then this equal to "\^B".. \^B is a control character is predefined for specify "Start of text(^B)" on your terminal device interface
(like putty,securecrt,different ssh clients and really terms) and
actually these are defined in termcap, terminfo and curses(for ex python use this) and
as VT100+,VT102,VT125.Vt400,XtermXX as some standarts (like ANSI standard XXXXX) and
shells use these loads of this meanings to char sets (such as ASCII cntrol character sets [C0,C1,G0,G1..within the ranges-> 000 to 037 and 200 to 237 octal,and it varies to different character sets)
you can view some cchars for your term.
# stty -a
actually you can use echo "-E" but ksh does not support that..
as ahamed said,"print -r" is good way for prints their literal value while use read -r in ksh and ksh derivatives.