I need to pass a filename parameter in shell script and then need to validate same name in the folder, Can any one help what would be piece of code to do so.
Lets folder is a and file with a is test.dat
and i want to pass this parameter against the file name file_name and then want to compare this name within the folder.If same then do otherwise return a error.
echo "At the start of Data Files Check " >> $REPFILE
#
if [ ! -f $P_INPUT_DIR/$P_FILENAME ]
then
echo $P_INPUT_DIR/$P_FILENAME " does not exist"
echo "**************************************************" >> $REPFILE
echo "*$P_SOURCE_DIR/$P_FILENAME " does not exist" *" >> $REPFILE
echo "**************************************************" >> $REPFILE
echo "*THE FILE "$P_FILENAME " does not exist in the *"$P_SOURCE_DIR >> $REPFILE
PROBLEMS=1
exit 1
after that I am executing a commaond
cd $P_INPUT_DIR
ls -rt | grep -v '^archive$' | sed '$d' | xargs -I{} mv {} archive/{}.orig
now i want to re start of Data Files Check in archive folder, the original file is just added with .orig then what would be additional line i need to write to do this also