LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Find error doing my head in ! (https://www.linuxquestions.org/questions/linux-general-1/find-error-doing-my-head-in-4175507851/)

SmurfGGM 06-12-2014 09:27 AM

Find error doing my head in !
 
Hi there,

Hopefully someone can help with this which his really doing my head in.

I have in a script ..

Code:

while read line
  do
    find $XHOME -type f -name $line | grep -v fixes > files.tmp
  done < files_list.tmp

When I run it from a script, I get this error ..

find: missing argument to `-name'

When I run the find command on its own outside of the script, it works fine.

Any idea's ?

Many thanks

allend 06-12-2014 10:06 AM

Perhaps you need to specify the full path to files_list.tmp?

BTW- When posting code please include between [CODE][/CODE] tags.

SmurfGGM 06-12-2014 10:15 AM

nope, that didn't fix it

(CODE fixed)

thanks

schneidz 06-12-2014 10:34 AM

can you please run it like so so we can get a display of what is going on:
Code:

echo XHOME = $XHOME
while read line
  do
echo line = $line
    find $XHOME -type f -name $line | grep -v fixes > files.tmp
  done < files_list.tmp

(others will suggest adding #!/bin/bash -x to the first line of the script for debugging purposes)

SmurfGGM 06-12-2014 10:39 AM

The $line & $CFXHOME are being picked up fine.

It just doesnt seem to line the -name from within the while loop :(


+ echo /home/test/gp/efin
/home/test/gp/efin
+ read line
+ echo line = acts035.fmt
line = acts035.fmt
+ find /home/test/gp/efin -type f -name acts035.fmt
+ grep -v fixes
+ read line
+ echo line = cfacs.mcs
line = cfacs.mcs
+ find /home/test/gp/efin -type f -name cfacs.mcs
+ grep -v fixes
+ read line
+ echo line = cfxdkerf.sqd
line = cfxdkerf.sqd
+ find /home/test/gp/efin -type f -name cfxdkerf.sqd
+ grep -v fixes
+ read line
+ echo line = mandate.sqd
line = mandate.sqd
+ find /home/test/gp/efin -type f -name mandate.sqd
+ grep -v fixes
+ read line
+ echo line = pops005.fmt
line = pops005.fmt
+ find /home/test/gp/efin -type f -name pops005.fmt
+ grep -v fixes
+ read line
+ echo line = reqs001.fmt
line = reqs001.fmt
+ find /home/test/gp/efin -type f -name reqs001.fmt
+ grep -v fixes
+ read line
+ echo line = reqs025.fmt
line = reqs025.fmt
+ find /home/test/gp/efin -type f -name reqs025.fmt
+ grep -v fixes
+ read line
+ echo line = s_postcode.sqd
line = s_postcode.sqd

+ find /home/test/gp/efin -type f -name s_postcode.sqd
+ grep -v fixes
+ read line
+ echo line = wndskdob.sqn
line = wndskdob.sqn
+ find /home/test/gp/efin -type f -name wndskdob.sqn
+ grep -v fixes
+ read line
+ echo line =
line =
+ find /home/test/gp/efin -type f -name
+ grep -v fixes
find: missing argument to `-name'
+ read line
++ date +%Y-%m-%d
+ DATE=2014-06-12

SmurfGGM 06-12-2014 10:41 AM

ahh, i've fixed it.

I had a blank line at the bottom of my input file.

Thanks for reading


All times are GMT -5. The time now is 09:13 PM.