Thursday, June 10, 2010

shell script to take backup of a file line by line

#!/bin/bash
l=`cat testing|wc -l`
for i in `seq 1 $l| sort -n -r`
do
sed -n "$i p" testing >> back
sed -i "$i d" testing
echo "deleted the line $i"
done

0 comments:

Post a Comment