I'm using a simple grep to look for "ISA" in the first 3 characters of a line in a file. If I type it on the qsh command line it returns 0 if the value isn't there or 1 if its the first 3 characters of the first line
grep -cF '^ISA' /home/Edi/IFSTextfile.txt
But if I run this from a script, it produces hex F025 instead of a 0. If I redirect the output to a file I can look at the file and see this
hex F0 is EBCDIC for 0 if my memory is correct, but I can't figure out a way to compare for that in my script
if [[ $(grep -cF '^ISA' /home/Edi/IFSTextfile.txt) > 0 ]]
then
echo "Above IS an EDI file"
else
echo "Above Not an EDI file"
fi
I tried the PASE version of grep too.
I'm at a loss how to get it to just send a 0 or 1 to the file. I am shocked I can't do something this simple without asking for help.
Has anyone else hit this kind of problem? I think its code page or CCSID related, but don't know how to fix it. Thanks for any ideas...
grep -cF '^ISA' /home/Edi/IFSTextfile.txt
But if I run this from a script, it produces hex F025 instead of a 0. If I redirect the output to a file I can look at the file and see this
hex F0 is EBCDIC for 0 if my memory is correct, but I can't figure out a way to compare for that in my script
if [[ $(grep -cF '^ISA' /home/Edi/IFSTextfile.txt) > 0 ]]
then
echo "Above IS an EDI file"
else
echo "Above Not an EDI file"
fi
I tried the PASE version of grep too.
I'm at a loss how to get it to just send a 0 or 1 to the file. I am shocked I can't do something this simple without asking for help.
Has anyone else hit this kind of problem? I think its code page or CCSID related, but don't know how to fix it. Thanks for any ideas...
Comment