Tuesday, May 26, 2015

Delete the file and checking the error status - shellscript

This script uses command line arguments ($1 and  $?) and tail out the /root/error.txt file.

#!/bin/bash
#usage of command line arguments
rm $1 2>>/root/error.txt
if [ $? -eq 0 ]
then
echo " Success "
else
tail -1 /root/error.txt
fi

0 Comments: