I am trying to perform some validations on the source files. the script has file name pattern as an argument.The Input file has Single quotes in the filename . I want to remove those single quotes and split the file into 2 parts. below is my code
FILE_NAME=$1
if [ -f $FILE_NAME ]
then
echo "\n Files are available to process \n"
else
echo "\n File does not exist: Process is Terminating \n"
exit 1
fi
for FILE_NAME in $FILE_NAME
do
eval mv -f '$FILE_NAME' $File_NAME
sed -ne '2,1p' $File_NAME > Hdr_$File_NAME
sed -ne '3,$p' $File_NAME > Dtl_$File_NAME
done
The problem is the split Files get renamed with zero bytes and the Single quotes still exist but the original files get renamed with data existing.
FILE_NAMES="$@"
if [ -f "$1" ]
then
echo "\n Files are available to process \n"
else
echo "\n Specified files do not exist: Process is Terminating \n"
exit 1
fi
for quoted_file_name in $FILE_NAMES
do
file_name=${quoted_file_name//\'/}
mv -f $quoted_file_name $file_name
sed -ne '1,2p' $file_name > Hdr_$file_name
sed -ne '3,$p' $file_name > Dtl_$file_name
done