Platform : RHEL 5.4
I have several .sql files in a directory. I want to comment lines 10 to 25 for all .sql files.
How can I do this ?
The symbol for comment in SQL is --
eg:
-- select salary from emp where empname = 'URS' ;
Platform : RHEL 5.4
I have several .sql files in a directory. I want to comment lines 10 to 25 for all .sql files.
How can I do this ?
The symbol for comment in SQL is --
eg:
-- select salary from emp where empname = 'URS' ;
Try:
sed '10,25 s/\(.*\)/-- \1/' infile.sql
To process all of the sql files in the current directory at once, you could try:
ec=0
for i in *.sql
do if sed '10,25s/^/-- /' $i > tmp$$.sql
then mv tmp$$.sql $i
else ec=1
rm -f tmp$$.sql
fi
done
exit $ec
And just for grins yet another 1 liner...
for i in *.sql ; do ex -s +"10,25 s/^/-- / | wq" $i ; done