Bash command stopping and not doing the third part

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I have this command that takes any video in a folder, it converts it in .ts segments and creates a m3u8 playlist.



I then need to concat them in a file playlist.txt, so this is what I'm doing:



cd /var/myfolder && find ./ -name "*.*" -exec ffmpeg -i -c:v h264 -crf 1 -flags +cgop -g 30 -hls_time 1 -hls_list_size 0 .m3u8 2>&1 > /dev/null ; && ls /var/myfolder/*.m3u8 | sed "s:.*/::" | xargs -i echo file > /var/myfolder/playlist.txt && echo done';


The first and second command work (cd in folder and ffmpeg conversion) then the command && ls /var/myfolder/*.m3u8 | sed "s:.*/::" | xargs -i echo file > /var/myfolder/playlist.txt && echo done'; is not executing.



I don't understand why is not executing the 3rd command.










share|improve this question



















  • 2




    presumably the find command is returning non-zero (failure), telling the && to stop.
    – Jeff Schaller
    Aug 13 at 13:04










  • Running the script with bash -x will also give you more debug.
    – Raman Sailopal
    Aug 13 at 13:11










  • I think Jeff is right, is it because Ffmpeg returns a stderr instead of a stdout maybe?
    – Mr.Web
    Aug 13 at 13:11










  • Redirecting errors to /dev/null and then asking us what's wrong seems extremely misdirected.
    – tripleee
    Aug 13 at 14:46










  • @tripleee the point is that ffmpeg does not stdout but always stderr any output.
    – Mr.Web
    Aug 13 at 14:49














up vote
0
down vote

favorite












I have this command that takes any video in a folder, it converts it in .ts segments and creates a m3u8 playlist.



I then need to concat them in a file playlist.txt, so this is what I'm doing:



cd /var/myfolder && find ./ -name "*.*" -exec ffmpeg -i -c:v h264 -crf 1 -flags +cgop -g 30 -hls_time 1 -hls_list_size 0 .m3u8 2>&1 > /dev/null ; && ls /var/myfolder/*.m3u8 | sed "s:.*/::" | xargs -i echo file > /var/myfolder/playlist.txt && echo done';


The first and second command work (cd in folder and ffmpeg conversion) then the command && ls /var/myfolder/*.m3u8 | sed "s:.*/::" | xargs -i echo file > /var/myfolder/playlist.txt && echo done'; is not executing.



I don't understand why is not executing the 3rd command.










share|improve this question



















  • 2




    presumably the find command is returning non-zero (failure), telling the && to stop.
    – Jeff Schaller
    Aug 13 at 13:04










  • Running the script with bash -x will also give you more debug.
    – Raman Sailopal
    Aug 13 at 13:11










  • I think Jeff is right, is it because Ffmpeg returns a stderr instead of a stdout maybe?
    – Mr.Web
    Aug 13 at 13:11










  • Redirecting errors to /dev/null and then asking us what's wrong seems extremely misdirected.
    – tripleee
    Aug 13 at 14:46










  • @tripleee the point is that ffmpeg does not stdout but always stderr any output.
    – Mr.Web
    Aug 13 at 14:49












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have this command that takes any video in a folder, it converts it in .ts segments and creates a m3u8 playlist.



I then need to concat them in a file playlist.txt, so this is what I'm doing:



cd /var/myfolder && find ./ -name "*.*" -exec ffmpeg -i -c:v h264 -crf 1 -flags +cgop -g 30 -hls_time 1 -hls_list_size 0 .m3u8 2>&1 > /dev/null ; && ls /var/myfolder/*.m3u8 | sed "s:.*/::" | xargs -i echo file > /var/myfolder/playlist.txt && echo done';


The first and second command work (cd in folder and ffmpeg conversion) then the command && ls /var/myfolder/*.m3u8 | sed "s:.*/::" | xargs -i echo file > /var/myfolder/playlist.txt && echo done'; is not executing.



I don't understand why is not executing the 3rd command.










share|improve this question















I have this command that takes any video in a folder, it converts it in .ts segments and creates a m3u8 playlist.



I then need to concat them in a file playlist.txt, so this is what I'm doing:



cd /var/myfolder && find ./ -name "*.*" -exec ffmpeg -i -c:v h264 -crf 1 -flags +cgop -g 30 -hls_time 1 -hls_list_size 0 .m3u8 2>&1 > /dev/null ; && ls /var/myfolder/*.m3u8 | sed "s:.*/::" | xargs -i echo file > /var/myfolder/playlist.txt && echo done';


The first and second command work (cd in folder and ffmpeg conversion) then the command && ls /var/myfolder/*.m3u8 | sed "s:.*/::" | xargs -i echo file > /var/myfolder/playlist.txt && echo done'; is not executing.



I don't understand why is not executing the 3rd command.







command-line find






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 13 at 13:04









Jeff Schaller

32.6k849110




32.6k849110










asked Aug 13 at 12:56









Mr.Web

1013




1013







  • 2




    presumably the find command is returning non-zero (failure), telling the && to stop.
    – Jeff Schaller
    Aug 13 at 13:04










  • Running the script with bash -x will also give you more debug.
    – Raman Sailopal
    Aug 13 at 13:11










  • I think Jeff is right, is it because Ffmpeg returns a stderr instead of a stdout maybe?
    – Mr.Web
    Aug 13 at 13:11










  • Redirecting errors to /dev/null and then asking us what's wrong seems extremely misdirected.
    – tripleee
    Aug 13 at 14:46










  • @tripleee the point is that ffmpeg does not stdout but always stderr any output.
    – Mr.Web
    Aug 13 at 14:49












  • 2




    presumably the find command is returning non-zero (failure), telling the && to stop.
    – Jeff Schaller
    Aug 13 at 13:04










  • Running the script with bash -x will also give you more debug.
    – Raman Sailopal
    Aug 13 at 13:11










  • I think Jeff is right, is it because Ffmpeg returns a stderr instead of a stdout maybe?
    – Mr.Web
    Aug 13 at 13:11










  • Redirecting errors to /dev/null and then asking us what's wrong seems extremely misdirected.
    – tripleee
    Aug 13 at 14:46










  • @tripleee the point is that ffmpeg does not stdout but always stderr any output.
    – Mr.Web
    Aug 13 at 14:49







2




2




presumably the find command is returning non-zero (failure), telling the && to stop.
– Jeff Schaller
Aug 13 at 13:04




presumably the find command is returning non-zero (failure), telling the && to stop.
– Jeff Schaller
Aug 13 at 13:04












Running the script with bash -x will also give you more debug.
– Raman Sailopal
Aug 13 at 13:11




Running the script with bash -x will also give you more debug.
– Raman Sailopal
Aug 13 at 13:11












I think Jeff is right, is it because Ffmpeg returns a stderr instead of a stdout maybe?
– Mr.Web
Aug 13 at 13:11




I think Jeff is right, is it because Ffmpeg returns a stderr instead of a stdout maybe?
– Mr.Web
Aug 13 at 13:11












Redirecting errors to /dev/null and then asking us what's wrong seems extremely misdirected.
– tripleee
Aug 13 at 14:46




Redirecting errors to /dev/null and then asking us what's wrong seems extremely misdirected.
– tripleee
Aug 13 at 14:46












@tripleee the point is that ffmpeg does not stdout but always stderr any output.
– Mr.Web
Aug 13 at 14:49




@tripleee the point is that ffmpeg does not stdout but always stderr any output.
– Mr.Web
Aug 13 at 14:49










1 Answer
1






active

oldest

votes

















up vote
1
down vote













You can't use shell redirects in find -exec.



xargs defaults to echo ... but since you already cd into the directory, we can substantially simplify the last line and get rid of both xargs and sed.



cd /var/myfolder && 
find ./ -name "*.*" -exec ffmpeg -i -c:v h264 -crf 1 -flags +cgop -g 30 -hls_time 1 -hls_list_size 0 .m3u8 ; 2>&1 > /dev/null &&
printf 'file %sn' *.m3u8 > /var/myfolder/playlist.txt &&
echo done





share|improve this answer




















  • well yeah, the redirections don't take effect just for the command started by find -exec, but for the whole find. But it doesn't matter where in the command line the redirections are set: writing find -exec ls -ld ; >output is the same as find -exec ls -ld >output ; or >output find -exec ls -ld ;
    – ilkkachu
    Aug 13 at 17:03











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f462294%2fbash-command-stopping-and-not-doing-the-third-part%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote













You can't use shell redirects in find -exec.



xargs defaults to echo ... but since you already cd into the directory, we can substantially simplify the last line and get rid of both xargs and sed.



cd /var/myfolder && 
find ./ -name "*.*" -exec ffmpeg -i -c:v h264 -crf 1 -flags +cgop -g 30 -hls_time 1 -hls_list_size 0 .m3u8 ; 2>&1 > /dev/null &&
printf 'file %sn' *.m3u8 > /var/myfolder/playlist.txt &&
echo done





share|improve this answer




















  • well yeah, the redirections don't take effect just for the command started by find -exec, but for the whole find. But it doesn't matter where in the command line the redirections are set: writing find -exec ls -ld ; >output is the same as find -exec ls -ld >output ; or >output find -exec ls -ld ;
    – ilkkachu
    Aug 13 at 17:03















up vote
1
down vote













You can't use shell redirects in find -exec.



xargs defaults to echo ... but since you already cd into the directory, we can substantially simplify the last line and get rid of both xargs and sed.



cd /var/myfolder && 
find ./ -name "*.*" -exec ffmpeg -i -c:v h264 -crf 1 -flags +cgop -g 30 -hls_time 1 -hls_list_size 0 .m3u8 ; 2>&1 > /dev/null &&
printf 'file %sn' *.m3u8 > /var/myfolder/playlist.txt &&
echo done





share|improve this answer




















  • well yeah, the redirections don't take effect just for the command started by find -exec, but for the whole find. But it doesn't matter where in the command line the redirections are set: writing find -exec ls -ld ; >output is the same as find -exec ls -ld >output ; or >output find -exec ls -ld ;
    – ilkkachu
    Aug 13 at 17:03













up vote
1
down vote










up vote
1
down vote









You can't use shell redirects in find -exec.



xargs defaults to echo ... but since you already cd into the directory, we can substantially simplify the last line and get rid of both xargs and sed.



cd /var/myfolder && 
find ./ -name "*.*" -exec ffmpeg -i -c:v h264 -crf 1 -flags +cgop -g 30 -hls_time 1 -hls_list_size 0 .m3u8 ; 2>&1 > /dev/null &&
printf 'file %sn' *.m3u8 > /var/myfolder/playlist.txt &&
echo done





share|improve this answer












You can't use shell redirects in find -exec.



xargs defaults to echo ... but since you already cd into the directory, we can substantially simplify the last line and get rid of both xargs and sed.



cd /var/myfolder && 
find ./ -name "*.*" -exec ffmpeg -i -c:v h264 -crf 1 -flags +cgop -g 30 -hls_time 1 -hls_list_size 0 .m3u8 ; 2>&1 > /dev/null &&
printf 'file %sn' *.m3u8 > /var/myfolder/playlist.txt &&
echo done






share|improve this answer












share|improve this answer



share|improve this answer










answered Aug 13 at 15:00









tripleee

4,84911626




4,84911626











  • well yeah, the redirections don't take effect just for the command started by find -exec, but for the whole find. But it doesn't matter where in the command line the redirections are set: writing find -exec ls -ld ; >output is the same as find -exec ls -ld >output ; or >output find -exec ls -ld ;
    – ilkkachu
    Aug 13 at 17:03

















  • well yeah, the redirections don't take effect just for the command started by find -exec, but for the whole find. But it doesn't matter where in the command line the redirections are set: writing find -exec ls -ld ; >output is the same as find -exec ls -ld >output ; or >output find -exec ls -ld ;
    – ilkkachu
    Aug 13 at 17:03
















well yeah, the redirections don't take effect just for the command started by find -exec, but for the whole find. But it doesn't matter where in the command line the redirections are set: writing find -exec ls -ld ; >output is the same as find -exec ls -ld >output ; or >output find -exec ls -ld ;
– ilkkachu
Aug 13 at 17:03





well yeah, the redirections don't take effect just for the command started by find -exec, but for the whole find. But it doesn't matter where in the command line the redirections are set: writing find -exec ls -ld ; >output is the same as find -exec ls -ld >output ; or >output find -exec ls -ld ;
– ilkkachu
Aug 13 at 17:03


















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f462294%2fbash-command-stopping-and-not-doing-the-third-part%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?