Shashikant shah

Wednesday, 18 February 2015

Check latest line add in file.

#!/bin/bash

Latest_dir=/home/shashi/latest

diff=$(diff ${Latest_dir}/test* | sed 1d | sed 's/<//g' | sed '/^$/d' | sed 's/^ //g' | wc -l)

new=$(diff ${Latest_dir}/test* | sed 1d | sed 's/<//g' | sed '/^$/d' | sed 's/^ //g' | awk '{print FNR ")" $0}')

if [ 0 = "$diff" ]; then

    echo "not a add latest line in file"
else
    cat << EOF
Latest line is :-
${new}
EOF

cop=$(cp -rf ${Latest_dir}/test ${Latest_dir}/test1)

fi

No comments:

Post a Comment