I have several files with extensions *.f90 in directory-A. I want to apply the following command for each file in shell script. e.g. filename.f90f2py -h filename.pyf -m filename /path/to/directory-A/filename.f90This will generate a .pyf file that I want to store in directory-B.I am using the following script. find /path/to/directory-A/ -name *.f90 -exec f2py -h {}.pyf -m {} {}.f90\;This uses the output of find function and replaces it in the -exec command in place of {}. which means that every where in place of {} my code will replace it with filename.f90. where as I want only the file name i.e. without extension to be placed in exec command in place of {}I tried using the basename command, it works in giving the filename only but {} in my original execute command still contains the the extension. I used following code.find /path/to/directory-A/ -name *.f90 -exec basename\ {} \ .f90; -exec f2py -h {}.pyf -m {} {}.f90\;How do I fix this issue. Also I want to execute my command in directory-B, so that the .pyf files are created in directory-B. how do I do this?
Shell Script: Use find to execute shell a command that contains filename(without extension) returned from find
shell script;find;exec
Use my favorite one-liner:cd directory-Afor i in *p90; do f2py -h ${i%.p90}.pyf -m ${i%.p90} $i; mv ${i%.p90}.pyf directory-B; doneYou have to understand that the extension is just a weird part of a file name in unix-like OSes and has no special treatment.You may need to fiddle with quotes in the one-liner if there are spaces or other weird symbols in file names.