I have a bunch of folders which have a subfolder somewhere called 360.
find . -name '360' -type d -exec 'echo "{}"' \;
output:
find: echo "./workspace/6875538616c6/raw/2850cd9cf25b/360": No such file or directory
For each found item, I want to do a curl call, and trigger a Jenkins build job.
My problem is that ./ part at the start. I should be able to cut it off like this:
find . -name '360' -type d -exec 'echo {} | cut -c 2-' \;
But because it starts with a ./ it will just be executed ("No such file or directory").
How can I get the output from find, without the leading ./
?
update:
Here is the whole thing with a jenkins curl call:
find reallylongfolderstructure -name '360' -type d -exec 'curl http://user:token@ourdomain.net/jenkins/job/jobname/buildWithParameters?token=ourtoken¶meter={}' \;
output
08:53:52 find: ‘curl http://user:token@ourdomain/jenkins/job/jobname/buildWithParameters?token=ourtoken¶meter=reallylongfolderstructure/something/lol/360’: No such file or directory
Best Answer
You write
This isn't what's happening. You have provided a single command to the
find ... -exec
parameter ofecho "{}"
. Note that this is notecho
and the directory found byfind
; it's a single command that includes a space in its name. Thefind
command (quite reasonably) cannot execute a command calledecho "./workspace/6875538616c6/raw/2850cd9cf25b/360"
.Remove the single quotes around the
-exec
parameter and you may find you don't need any additional changes or workarounds:Similarly here you need to remove the quoting of the entire value passed to
-exec
. But in this case you still need to quote the storage arguments so the shell cannot interpret&
, etc.