Shell script to process files

Posted by Harish on Stack Overflow See other posts from Stack Overflow or by Harish
Published on 2010-03-17T06:05:45Z Indexed on 2010/03/17 6:11 UTC
Read the original article Hit count: 324

Filed under:
|
|
|

I need to write a Shell Script to process a huge folder of nearly 20 levels.I have to process each and every file and check which files contain lines like select insert update

When I mean line it should take the line till I find a semicolon in that file. I should get a result like this

C:/test.java   select * from dual
C:/test.java   select * from test
C:/test1.java  select * from tester
C:/test1.java  select * from dual

and so on.Right now I have a script to read all the files

#!bin/ksh

FILE=<FILEPATH to be traversed>
TEMPFILE=<Location of Temp file>
cd $FILE    
for f in `find . ! -type d`; 
do
cat $FILE/addedText.txt>>$TEMPFILE/newFile.txt
cat $f>>$TEMPFILE/newFile.txt
rm $f
cat $TEMPFILE/newFile.txt>>$f
rm $TEMPFILE/newFile.txt
done

I have very little knowledge of awk and sed to proceed further in reading each file and achieve what I want to.Can anyone help me in this

© Stack Overflow or respective owner

Related posts about unix

Related posts about file