Problems with find

Problems with find

Post by jimbob4.. » Sat, 20 Jan 2001 22:48:55



 Hi,

I have the following code that is suppose to find all the files
containing the text I direct into the script and output the file name
and what was found.

#! /bin/ksh
#need to call this script passing in a file containing
#the desired search text
list_file=grep_through_each_file.lst
tempfile=/tmp/grep_through_each_file$$
echo "$here"
echo "Did you provide as stdin the key file listing all search strings,
one per line???   grep_through_each_file.sh < $list_file"
echo "Retrieve results from $list_file"
#. /usr/test/sqa/idb/prod/bin/init_oracle_sitar_prdata.ksh
#cd /usr/prod/cct_cigproduct/mstar/mstardata/cig_prod/emx2500.prod/pr
chmod 777 $list_file
while read pr_num
do
if [[ $pr_num != \#* ]]
then
        find . -type f -name '*' -print | while read i
        do
          sed -n '/$pr_num/p' $i >> $tempfile
        done
        echo "$pr_num"
    print "end of data for $pr_num" >> $tempfile
fi
done

mv $tempfile $list_file
exit

I get as output for each file searched

if [[ $pr_num != \#* ]]
          sed -n '/$pr_num/p' $i >> $tempfile
        echo $pr_num
    print end of data for $pr_num >> $tempfile

Sent via Deja.com
http://www.deja.com/

 
 
 

Problems with find

Post by jimbob4.. » Sat, 20 Jan 2001 23:32:23


I found one problem

the print in this line was printing everything -
find . -type fname '*' -print | while read i

I took it out, but I do not get any output except what is given by the
print line.

I want to see what was found by the sed



>  Hi,

> I have the following code that is suppose to find all the files
> containing the text I direct into the script and output the file name
> and what was found.

> #! /bin/ksh
> #need to call this script passing in a file containing
> #the desired search text
> list_file=grep_through_each_file.lst
> tempfile=/tmp/grep_through_each_file$$
> echo "$here"
> echo "Did you provide as stdin the key file listing all search
strings,
> one per line???   grep_through_each_file.sh < $list_file"
> echo "Retrieve results from $list_file"
> #. /usr/test/sqa/idb/prod/bin/init_oracle_sitar_prdata.ksh
> #cd /usr/prod/cct_cigproduct/mstar/mstardata/cig_prod/emx2500.prod/pr
> chmod 777 $list_file
> while read pr_num
> do
> if [[ $pr_num != \#* ]]
> then
>    find . -type f -name '*' -print | while read i
>    do
>      sed -n '/$pr_num/p' $i >> $tempfile
>    done
>    echo "$pr_num"
>     print "end of data for $pr_num" >> $tempfile
> fi
> done

> mv $tempfile $list_file
> exit

> I get as output for each file searched

> if [[ $pr_num != \#* ]]
>           sed -n '/$pr_num/p' $i >> $tempfile
>         echo $pr_num
>     print end of data for $pr_num >> $tempfile

> Sent via Deja.com
> http://www.deja.com/

--

Sent via Deja.com
http://www.deja.com/

 
 
 

Problems with find

Post by Barry Margoli » Sun, 21 Jan 2001 03:57:54



> Hi,

>I have the following code that is suppose to find all the files
>containing the text I direct into the script and output the file name
>and what was found.

Since you have the argument to sed in single-quotes, variables aren't
expanded.  Change it to "/$pr_num/p" and it should work.

But wouldn't it be simpler to use grep?

find . -type f -name '*' -exec grep "$pr_num" {} \;

Quote:

>#! /bin/ksh
>#need to call this script passing in a file containing
>#the desired search text
>list_file=grep_through_each_file.lst
>tempfile=/tmp/grep_through_each_file$$
>echo "$here"
>echo "Did you provide as stdin the key file listing all search strings,
>one per line???   grep_through_each_file.sh < $list_file"
>echo "Retrieve results from $list_file"
>#. /usr/test/sqa/idb/prod/bin/init_oracle_sitar_prdata.ksh
>#cd /usr/prod/cct_cigproduct/mstar/mstardata/cig_prod/emx2500.prod/pr
>chmod 777 $list_file
>while read pr_num
>do
>if [[ $pr_num != \#* ]]
>then
>    find . -type f -name '*' -print | while read i
>    do
>      sed -n '/$pr_num/p' $i >> $tempfile
>    done
>    echo "$pr_num"
>    print "end of data for $pr_num" >> $tempfile
>fi
>done

>mv $tempfile $list_file
>exit

>I get as output for each file searched

>if [[ $pr_num != \#* ]]
>          sed -n '/$pr_num/p' $i >> $tempfile
>        echo $pr_num
>    print end of data for $pr_num >> $tempfile

>Sent via Deja.com
>http://www.deja.com/

--

Genuity, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
 
 
 

1. Linux 2.4.x Kernel Bug - Problem NOT found, but found workaround

Hello again,

    I followed your suggestion and tried to find where
exactly did the kernel
hang, by using an infinite loop and blinking floppy
LED (sorry, the kbd leds
didn't work, except in DOS).
    I ended up in protected mode, in
[arch/i386/kernel/head.S] where I managed
to find a SOLUTION for the problem (HAVEN'T FOUND THE
PROBLEM (I THINK)).

Here is the modification I've made (sorry for not
sending a diff, I've lost the
original file :P )

This is from KERNEL 2.4.18

-------------(
arch/i386/kernel/head.S)------------------------------------
        orl %eax,%eax                   # do we have
processor info as well?
        je is486

#       movl $1,%eax            # Use the CPUID
instruction to get CPU type
#       cpuid                   # <- This CPUID thing
hangs the machine
                                # With it, there's a
lock, without it, a reboot :(
# I've noticed that this code is the same in 2.2.20
kernel, which works perfectly!!!
#       movb %al,%cl            # save reg for future
use
#       andb $0x0f,%ah          # mask processor
family
#       movb %ah,X86
#       andb $0xf0,%al          # mask model
#       shrb $4,%al
#       movb %al,X86_MODEL
#       andb $0x0f,%cl          # mask mask revision
#       movb %cl,X86_MASK
#       movl %edx,X86_CAPABILITY

        movb    $4, %al         #
        movb    %al, X86_MODEL  #
        movb    $5, %al         # Hardcoded the CPUID
results (except edx...)
        movb    %al, X86        # and... the kernel
works fine!
        movb    $2, %al         #
        movb    %al, X86_MASK   #
is486:
-----------------------------------------------------------------------------

Why is this happening?

Thanks for your support.

__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

2. Motherboard/case question

3. problem with find and cwd on new AIX 4.3.0

4. kstat

5. modem problem: Linux finds "unknown" on Socket 2

6. overriding the default htaccess

7. Problems with FIND...

8. Authentications based on directory

9. rpm 2.2 problem, cannot find dependencies

10. Xdoom problems - cannot find STBAR

11. problem in finding default audio driver for USB

12. Problem with find?

13. problem with find cmd