Can anyone help me in shell script function with these four operation.
First removing the last line in the file and then removing the " from the file and followed by getting the file name and then getting the count of the line in the file
Also want to display file name and line count but this shell is giving me error
can anyone assist where it goes wrong
1)
sed -n '$!p' test>temp
mv temp $v_file
2)
sed 's/"//g' test.csv>temp
mv temp test.csv
3)ls -lrt *.CSV | awk '{print $9}'|grep -v "^d"
4)wc -l test.csv
getfilename()
{
cd $DATDIR
v_file=`ls -lrt *.CSV | awk '{print $9}'|grep -v "^d"`
echo $v_file
# remove last line
sed -n '$!p' $v_file>temp
mv temp $v_file
# remove " in the file
sed 's/"//g' $v_file>temp
mv temp $v_file
# word count
linecount=`wc -l '{$v_file}`
echo $linecount
}
thanks in advance