LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-26-2017, 01:59 PM   #16
Laserbeak
Member
 
Registered: Jan 2017
Location: Manhattan, NYC NY
Distribution: Mac OS X, iOS, Solaris
Posts: 508

Rep: Reputation: 143Reputation: 143

Quote:
Originally Posted by azurite View Post
the script is executable and I fixed the shebang as you suggested. Now, I get the following error.

Code:
username@computer:~/Desktop/DWITESTSUB$ find . -name '*.ecclog' -exec /home/natasha/Desktop/
DWITESTSUB/ec_plot.sh
find: missing argument to `-exec'
What about the:

Code:
{} \;
{} is replaced for each file that matches the find parameters, and \; ends the -exec subcommand, so it's:

Code:
find basedir -name '*.myfiletype' -exec /my/program/to/run {} \;
 
Old 06-26-2017, 02:06 PM   #17
azurite
LQ Newbie
 
Registered: May 2016
Posts: 29

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Laserbeak View Post
What about the:

Code:
{} \;
{} is replaced for each file that matches the find parameters, and \; ends the -exec subcommand, so it's:

Code:
find basedir -name '*.myfiletype' -exec /my/program/to/run {} \;
ah sorry, I did include the {} \; but still the same error. I'm not too familiar with the syntax difference between scripts written for sh or bash. Could anyone take a look at the original script that I need to run and see if there's a problem with that and how I'm running the find commands? I got the script from a forum for the software that its calling up so maybe there's differences between that script and how I'm running it on my computer?
I apologize for bothering everyone with this, just wish I could figure it out and run it without any more problems.
 
Old 06-26-2017, 02:10 PM   #18
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
take a peek at post 15 and try it again
 
Old 06-26-2017, 02:51 PM   #19
Laserbeak
Member
 
Registered: Jan 2017
Location: Manhattan, NYC NY
Distribution: Mac OS X, iOS, Solaris
Posts: 508

Rep: Reputation: 143Reputation: 143
Did you ever do what I suggested before and put an echo before the command, so it'd be:

Code:
... -exec echo shellprog.sh ....
and post a few lines of output if you don't immediately see something glaringly wrong?
 
Old 06-26-2017, 03:02 PM   #20
Laserbeak
Member
 
Registered: Jan 2017
Location: Manhattan, NYC NY
Distribution: Mac OS X, iOS, Solaris
Posts: 508

Rep: Reputation: 143Reputation: 143
For an example, if I go to my home directory and type in:

Code:
find . -name '*.c' -exec echo someshellprogram {} \;
I get an ungodly amount of C source files, but assuming someshellprogram actually exists and this is just a dry run to see what will be done, you can see it's quite useful. Here's a very small random clipping from the output:

Code:
someshellprogram ./ex-vi/ex_tagio.c
someshellprogram ./ex-vi/ex_temp.c
someshellprogram ./ex-vi/ex_tty.c
someshellprogram ./ex-vi/ex_unix.c
someshellprogram ./ex-vi/ex_v.c
someshellprogram ./ex-vi/ex_vadj.c
someshellprogram ./ex-vi/ex_version.c
someshellprogram ./ex-vi/ex_vget.c
someshellprogram ./ex-vi/ex_vmain.c
someshellprogram ./ex-vi/ex_voper.c
someshellprogram ./ex-vi/ex_vops.c
someshellprogram ./ex-vi/ex_vops2.c
someshellprogram ./ex-vi/ex_vops3.c
someshellprogram ./ex-vi/ex_vput.c
someshellprogram ./ex-vi/ex_vwind.c
someshellprogram ./ex-vi/expreserve.c
someshellprogram ./ex-vi/exrecover.c
someshellprogram ./ex-vi/libterm/termcap.c
someshellprogram ./ex-vi/libterm/tgoto.c
someshellprogram ./ex-vi/libterm/tputs.c
someshellprogram ./ex-vi/malloc.c
someshellprogram ./ex-vi/mapmalloc.c
someshellprogram ./ex-vi/printf.c
someshellprogram ./google-cloud-sdk/.install/.backup/platform/gsutil/third_party/crcmod/python2/src/_crcfunext.c
someshellprogram ./google-cloud-sdk/.install/.backup/platform/gsutil/third_party/crcmod/python3/src/_crcfunext.c
someshellprogram ./google-cloud-sdk/platform/gsutil/third_party/crcmod/python2/src/_crcfunext.c
someshellprogram ./google-cloud-sdk/platform/gsutil/third_party/crcmod/python3/src/_crcfunext.c
someshellprogram ./grub-2.02/grub-core/boot/decompressor/minilib.c
someshellprogram ./grub-2.02/grub-core/boot/decompressor/none.c
someshellprogram ./grub-2.02/grub-core/boot/decompressor/xz.c
someshellprogram ./grub-2.02/grub-core/bus/bonito.c
someshellprogram ./grub-2.02/grub-core/bus/cs5536.c
someshellprogram ./grub-2.02/grub-core/bus/emu/pci.c
someshellprogram ./grub-2.02/grub-core/bus/i386/ieee1275/pci.c
someshellprogram ./grub-2.02/grub-core/bus/pci.c
someshellprogram ./grub-2.02/grub-core/bus/usb/ehci.c
someshellprogram ./grub-2.02/grub-core/bus/usb/ohci.c
someshellprogram ./grub-2.02/grub-core/bus/usb/serial/common.c
someshellprogram ./grub-2.02/grub-core/bus/usb/serial/ftdi.c
someshellprogram ./grub-2.02/grub-core/bus/usb/serial/pl2303.c
someshellprogram ./grub-2.02/grub-core/bus/usb/serial/usbdebug_late.c
someshellprogram ./grub-2.02/grub-core/bus/usb/uhci.c
someshellprogram ./grub-2.02/grub-core/bus/usb/usb.c
someshellprogram ./grub-2.02/grub-core/bus/usb/usbhub.c
someshellprogram ./grub-2.02/grub-core/bus/usb/usbtrans.c
someshellprogram ./grub-2.02/grub-core/commands/acpi.c
Actually looking at this gave me an additional idea. You might want to replace the dot for current working directory into the full directory name like this (might as well make the shell program one too)::

Code:
find /Users/djohnsto -name '*.c' -exec echo /path/to/someshellprogram {} \;
Then the output is a full pathname:

Code:
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509/by_dir.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509/by_file.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509/t_crl.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509/t_req.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509/t_x509.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509/x509_att.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509/x509_cmp.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509/x509_d2.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509/x509_def.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509/x509_err.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509/x509_ext.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509/x509_lu.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509/x509_obj.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509/x509_r2x.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509/x509_req.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509/x509_set.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509/x509_trs.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509/x509_txt.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509/x509_v3.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509/x509_vfy.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509/x509_vpm.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509/x509cset.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509/x509name.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509/x509rset.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509/x509spki.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509/x509type.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509/x_all.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509/x_attrib.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509/x_crl.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509/x_exten.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509/x_name.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509/x_pubkey.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509/x_req.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509/x_x509.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509/x_x509a.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509v3/pcy_cache.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509v3/pcy_data.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509v3/pcy_lib.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509v3/pcy_map.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509v3/pcy_node.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509v3/pcy_tree.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509v3/tabtest.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509v3/v3_addr.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509v3/v3_akey.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509v3/v3_akeya.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509v3/v3_alt.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509v3/v3_asid.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509v3/v3_bcons.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509v3/v3_bitst.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509v3/v3_conf.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509v3/v3_cpols.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509v3/v3_crld.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509v3/v3_enum.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509v3/v3_extku.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509v3/v3_genn.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509v3/v3_ia5.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509v3/v3_info.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509v3/v3_int.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509v3/v3_lib.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509v3/v3_ncons.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509v3/v3_pci.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509v3/v3_pcia.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509v3/v3_pcons.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509v3/v3_pku.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509v3/v3_pmaps.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509v3/v3_prn.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509v3/v3_purp.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509v3/v3_skey.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509v3/v3_sxnet.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509v3/v3_tlsf.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509v3/v3_utl.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509v3/v3conf.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509v3/v3err.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/crypto/x509v3/v3prin.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/demos/bio/client-arg.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/demos/bio/client-conf.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/demos/bio/saccept.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/demos/bio/sconnect.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/demos/bio/server-arg.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/demos/bio/server-cmod.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/demos/bio/server-conf.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/demos/cms/cms_comp.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/demos/cms/cms_ddec.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/demos/cms/cms_dec.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/demos/cms/cms_denc.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/demos/cms/cms_enc.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/demos/cms/cms_sign.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/demos/cms/cms_sign2.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/demos/cms/cms_uncomp.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/demos/cms/cms_ver.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/demos/evp/aesccm.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/demos/evp/aesgcm.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/demos/pkcs12/pkread.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/demos/pkcs12/pkwrite.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/demos/smime/smdec.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/demos/smime/smenc.c
/path/to/someshellprogram /Users/djohnsto/Downloads/openssl-1.1.0e/demos/smime/smsign.c
That could help... I don't know, I'm a bit grasping at straws here.

Last edited by Laserbeak; 06-26-2017 at 03:12 PM.
 
Old 06-29-2017, 02:30 PM   #21
azurite
LQ Newbie
 
Registered: May 2016
Posts: 29

Original Poster
Rep: Reputation: Disabled
Hi guys,

So I took your suggestions and tried them all. Please take a look at the things I ran below.

For Reference here is the script again. Perhaps there's some variable in the script that I need to change? Note: I tried running the codes with and without the italicized portion of the script but in both instances, it output errors.

Ran:
1. Ran Tree to make sure that the file I was looking for is present in the subfolders. It was.
2. Ran pwd to make sure I was still in the correct directory.
3. Ran ls to make sure the directory folder had all the correct files and scripts. It did.
4. Ran the find code provided with 'echo' - seemed okay
5. Ran the find code without absolute paths - error
6. Ran the find code with absolute paths - error

Please check if I have done everything correctly.


I have been racking my brain trying to figure this out but it's only frustrating me more. It would really be a HUGE help if I can get this to work!

Last edited by azurite; 07-06-2017 at 11:07 PM.
 
Old 06-29-2017, 02:49 PM   #22
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
first I'd stop being in Desktop when running this. second I personally would code paths in the script, but that last part is deff me,

Code:
TARDIS@ubuntu:~/DWI$ find . -name '*.ecclog' -exec ec_plot.sh {} \;
find: ‘ec_plot.sh’: No such file or directory
find: ‘ec_plot.sh’: No such file or directory
find: ‘ec_plot.sh’: No such file or directory
where is the script located when using the dot for path in find?
what directory are you in when in the terminal running the find using the dot?

Code:
TARDIS@ubuntu:~/DWI$ find /home/TARDIS/Desktop/DWI -name '*.ecclog' -exec /home/TARDIS/Desktop/DWI/ec_plot.sh {} \;
find: ‘/home/TARDIS/Desktop/DWI’: No such file or directory
TARDIS@ubuntu:~/DWI$
again using the directory Desktop, I'd shy away from that like a 11yr old boy at a school dance.


actully open a file manager and create a different directory like 'scripts'

the way it is looking at it using find.
Code:
 find [path to files needing processing] -name '*.ecclog' -exec [path where script is located]/ec_plot.sh {} \;
that desktop folder might be what is throwing this off.

Last edited by BW-userx; 06-29-2017 at 02:51 PM.
 
Old 06-29-2017, 06:51 PM   #23
Laserbeak
Member
 
Registered: Jan 2017
Location: Manhattan, NYC NY
Distribution: Mac OS X, iOS, Solaris
Posts: 508

Rep: Reputation: 143Reputation: 143
Yes, it looks like you're still not putting in the full path to your script. Plus try to copy and paste one of those echo'ed command to the command line and see if you still get the same error.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make a loop to enter in a folder and then in its subfolders. (BASH) asero12 Programming 2 11-14-2013 11:29 PM
[SOLVED] Help making specific script loop over multiple files in directory novloski Linux - Newbie 3 05-11-2011 05:13 AM
[SOLVED] Shell Script - Use variable in a for loop with directory path Tech109 Linux - General 2 01-19-2011 10:22 AM
[SOLVED] Bash help needed: How to recursively browse subfolders in a for loop? frisil Linux - General 13 02-20-2010 12:08 AM
Loop through all files in a directory. Bash/Perl script? Nzo Linux - Newbie 9 12-09-2009 07:09 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:59 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration