2013年1月18日 星期五

[Sed] Determine sed substitution success or fail

[Sed] Determine sed substitution success or fail

#!/bin/bash



# output the file, if find root , then print root in the output file

sed -n  '/root/p' ./passwd > output



FILE='output'









# determine the file, if file is empty then no find

if [ -s $FILE ] ; then

    echo "$FILE has data."

    rm $FILE

else

    echo "$FILE is empty."

    rm $FILE

fi

Reference :


Related Posts:

0 意見:

張貼留言