i have the following perl script.but it searches for a given filename.
i want to run the same script in my directoy which has subdirectories too and it has to display the file if sreach satisfies along with directory name.
can anyone help me:
perl script:
my $FILE = $ARGV[0];
for zf in *.bteq; do
if ($FILE eq "" )
{
print "File name $FILE not found \n";
exit;
}
my $count=0;
open(IN_FILE, $FILE) or die "cannot open outfile.txt:" . "$!";
my $comment = true;
my $FND = false;
while ($line=<IN_FILE>)
{
$count++;
if ($line =~ /^\/\/ || $line =~ /^\../)
{
my $comment = true;
next;
}
if ($comment eq "true")
{
if ( $line =~ /\*\/$/)
{
next;
}
else
{
$comment = false;
}
}
not sure if I have understood this. why do you want to use perl for finding the file ? can't you use 'find' with 'exec' option ? am I missing something ?
list_files()
{
if [ -f $1 ]
then echo $1; return;
fi
cd $1
echo; echo "Processing---> `pwd`:"; #Display Directory name
for i in *
do
if test -d $i #if dictionary
then
list_files $i #recursively list files
cd ..
else
echo $i; #Display File name
perl /home/sa230329/parse_bteq.pl $i
fi
done
}
if [ $# -eq 0 ]
then
echo "No Directory to list"
echo "Usage: recursive_dir_Parse.sh [Directory to list and Parse]"
exit 0
fi
for i in $*
do
DIR=$1
list_files $DIR #shift 1 #To read next directory/file name
done
now i need some more modifications to this ..
the above script is listing the create table definition as required but i want the script to exclude one specific directory called "CTRL"
is there any way to do this ..