Hi, I have one file, I need to check if file exist or not and then remove the lines which starts with ?
My file1.out data is some thing
abcabcppp
xyzxyzpqr
?????????
?????????
Output should be in test.out
abcabcppp
xyzxyzpqr
I am getting the output as below but the File does not exist in the directory..
I can see FN: is displayed in quotes "File1.out", Can some one please tell me what is wrong in this
I have written the following Code
#!/bin/ksh
set -A args $*
echo "Arguments "
outfile_string=${args[8]}
outfile_string=`echo ${outfile_string} | tr -d '"'`
echo 'OUTFILE_STRING : '$outfile_string
FN=$USR/tmp/${args[8]}
echo "FN :" $FN
nfile_name=${args[9]}
nfile_name=`echo ${nfile_name} | tr -d '"'`
echo 'Final File Name : '$nfile_name
#******** Check
if test -s ${FN}
then
echo "File exist "
#ln_number=`grep -c '?' ${outfile_string}`
else
echo "File does not exist "
fi
==========================================
Output for the above code
Arguments
OUTFILE_STRING : File1.out
FN : /usr/tmp/"File1.out"
Final File Name : test.out
File does not exist
=============================================
If i declare this way
FN=$USR/tmp/${args[8]}
out put is
FN : /usr/tmp/"File1.out"
If i declare this way I am getting File Exist,
FN="$USR/tmp/File1.out"
FN : /usr/tmp/File1.out
but after this i need to search for the lines which start with ? and remove them and write to new file
Can some one please tell me how to do this.