I've got this bash one-liner , it runs fine on OSX, but doesn't on Linux, I'm suspecting the linux distro (Busybox) on my Qnap has got something to do with this .

Here is the command that runs on OSX :

find . -type f -name "*.mp4" -exec bash -c 'ffmpeg -i "$0" -c:v copy -c:a libfaac -af "volume=23dB" "fix/$0"' '{}' \;

Now on the Qnap:

find . -type f -name "*.mp4" -exec bash -c 'ffmpeg -i "$0" -c:v copy -c:a libfaac -af "volume=23dB" "fix/$0"' '{}' \;

returns :

BusyBox v1.01 (2015.05.21-17:32+0000) multi-call binary

Usage: find [PATH...] [EXPRESSION]

Search for files in a directory hierarchy. The default PATH is the current directory; default EXPRESSION is '-print'

EXPRESSION may consist of: -follow Dereference symbolic links. -name PATTERN File name (leading directories removed) matches PATTERN. -print Print (default and assumed).

-type X Filetype matches X (where X is one of: f,d,l,b,c,...) -perm PERMS Permissions match any of (+NNN); all of (-NNN); or exactly (NNN) -mtime TIME Modified time is greater than (+N); less than (-N); or exactly (N) days

Like if the find command wasn't working, so if I execute the find command alone :

find . -type f -name "*.mp4"

it works just fine, I get all my files, so I suspect the problem is passing the files to the exec command, and that's where I can't figure it out

bash version osx : GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin14)

bash version linux : GNU bash, version 3.2.57(1)-release (i686-pc-linux-gnu)

  • Why don't you just pipe? In this particular case it's easier to debug if you pipe. – theoden Aug 1 '15 at 23:52
  • BusyBox isn't your typical Linux system (i.e., mostly POSIX with some extensions). Rather, BusyBox is a collection of utilities which lack many features. On the positive side, a script that you can run on BusyBox is likely to run on other systems. The question should be retitled to say "BusyBox". – Thomas Dickey Aug 1 '15 at 23:58
  • Good idea, how would I pipe each file to ffmpeg ? – fingertwist Aug 1 '15 at 23:58
  • @ThomasDickey yeah, that's what I suspect, don't know how to get around it to get my one liner to work on Busybox .. – fingertwist Aug 1 '15 at 23:59
  • I wouldn't try it as a one-liner: making the complicated argument of -exec into a separate script would probably be a good starting point. By keeping the pieces simple, you can pinpoint the limitations to work around one-by-one. – Thomas Dickey Aug 2 '15 at 0:01

I suspect it's based on the single/double quote positioning tripping up find.

Typically I always use something like this in a script file (say conv.sh) for more complex operations:

find . -type f -name "*.mp4" | while read FILE
  ffmpeg -i "$FILE" -c:v copy -c:a libfaac -af "volume=23dB" "fix/$FILE"

Now run this file with debugging:

bash -xv ./conv.sh

A quick and dirty script that should work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.