V
V
Vasily Nikonov2021-03-19 23:31:14
bash
Vasily Nikonov, 2021-03-19 23:31:14

When passing the result to bash, I can't create a variable. Why?

There are search criteria, which are then passed to Bash for further processing: creating a file name and converting via FFmpeg.

There is an example file structure.
605505b5db522906655262.png

When I use the find command to find the files I need with their paths and simply ask them to output them, the utility works just perfect.
The result of the find command.
605505d73ae4b808908011.png

But if you redirect this execution to Bash to, for example, create a variable, edit its name and then pass it to FFmpeg for conversion, something like this happens:
Execution result redirected to Bash.

6055075037a76942458585.png
find ~/Desktop/Serial -type f \( -name "*.mkv" -o -name "*.avi" \) -exec sh -c 'path={}; echo $path' \;


If you simply ask to withdraw a variable from the result of execution, then it works out adequately:
Just echo.
605507bf3adb3965795900.png


Please tell me how to solve this problem. Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Nikonov, 2021-03-19
@jintaxi

This problem is solved by simply quoting the assigned variable name.
605510672b224845818061.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question