As I read the man page, the -exec option does not execute multiple commands in parallel. With the ; suffix, it substitutes a single file in the command. With the + suffix, it substitutes multiple files in the command. Either way, it runs a single command at a time.
|
Quote:
Code:
find . -type f -name '*.ogg' -print0 | xargs -0 -n 1 -P 2 ./transcode.sh Please forgive me for imposing on your patience by belaboring this point, but when I first began using find (in place of ls) I assumed one would feed its output through a pipe to the next command, as one does with ls. Surprise, it didn't work, had to use the -exec option to get it to go. Yet here you are using a pipe for find's output. The only other difference is your use of -print0, but that seems to be for the benefit of xargs -0, not for enabling the pipe. |
Forgive me my ignorance, but doesn't xargs expect to be fed from stdin? So does this even work with the -exec option, since it does not have a pipe to stdin?
|
Quote:
The net result will be a single execution of ./transcode.sh with all of the filenames as arguments (i.e., a single thread). |
Quote:
I'm operating on these premises: 1) Any linux cli app accepts input from stdin 2) A pipe feeds the output of the previous app through stdin to the subsequent app 3) My earlier experience with find was that its output won't pipe, you use the -exec option to feed find's output to a subsequent app 4) BenCollver2 gave an example showing find will send output through a pipe, so my premise 3) is wrong Code:
find . -type f -name '*.ogg' -print0 | xargs -0 -n 1 -P 2 ./transcode.sh Why does find have an -exec option at all? Why not just use a pipe in all cases? |
Quote:
|
I recommend using dual disks. Get the fastest ones you can then read from one and write to the other. Using an ext2 temporary partition just for enconding also helps (no file system journal to slow you down). Ultimately, if your output is not too big less than 1G you can save the temporary encoded file to memory /dev/shm. However make sure you have enough free memory, lower the swappiness and also move the temp file right after it is created (add that to the script).
|
Quote:
Code:
find . -type f -name '*.ogg' -print0 | xargs -0 -n 1 -P 2 ./transcode.sh But in Code:
find . -type f -name '*.ogg' -print0 -exec xargs -0 -n 1 -P 2 ./transcode.sh {} + So if I have that right, then it means that a pipe feeds the previous app's output singly, line by line, to the subsequent app. But find's -exec option concatenates all the lines of output produced by find and feeds that concatenation as a single item to the subsequent app. Is that correct? |
Quote:
– You can use more than one -exec to find. – Some -exec variants execute the command after changing the working directory to the location of the found file. |
Quote:
Code:
echo foobar | find . -type f -name '*.ogg' -print0 -exec xargs -0 -n 1 -P 2 ./transcode.sh {} + |
Quote:
Code:
[rkn] ~ $ wc /etc/profile /etc/fstab Code:
[rkn] ~ $ find /etc/profile /etc/fstab -print | wc Code:
[rkn] ~ $ cat /etc/passwd | wc /etc/profile /etc/fstab The xargs command reads from stdin and uses that data to generate a list of arguments to the prototype command line: Code:
[rkn] ~ $ echo /etc/profile /etc/fstab | xargs wc Code:
[rkn] ~ $ echo /etc/profile /etc/fstab | xargs wc /etc/passwd Code:
[rkn] ~ $ find /etc/profile /etc/fstab -print0 | wc --files0-from=- |
Quote:
Code:
ffmpeg -i input.avi -vcodec libx264 -acodec aac movie.mp4 |
Quote:
Quote:
|
Quote:
|
All times are GMT -5. The time now is 12:20 AM. |