Bash command stopping and not doing the third part
Clash 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.
command-line find
 |Â
show 1 more comment
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.
command-line find
2
presumably thefind
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
 |Â
show 1 more comment
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.
command-line find
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
command-line find
edited Aug 13 at 13:04
Jeff Schaller
32.6k849110
32.6k849110
asked Aug 13 at 12:56
Mr.Web
1013
1013
2
presumably thefind
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
 |Â
show 1 more comment
2
presumably thefind
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
 |Â
show 1 more comment
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
well yeah, the redirections don't take effect just for the command started byfind -exec
, but for the wholefind
. But it doesn't matter where in the command line the redirections are set: writingfind -exec ls -ld ; >output
is the same asfind -exec ls -ld >output ;
or>output find -exec ls -ld ;
â ilkkachu
Aug 13 at 17:03
add a comment |Â
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
well yeah, the redirections don't take effect just for the command started byfind -exec
, but for the wholefind
. But it doesn't matter where in the command line the redirections are set: writingfind -exec ls -ld ; >output
is the same asfind -exec ls -ld >output ;
or>output find -exec ls -ld ;
â ilkkachu
Aug 13 at 17:03
add a comment |Â
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
well yeah, the redirections don't take effect just for the command started byfind -exec
, but for the wholefind
. But it doesn't matter where in the command line the redirections are set: writingfind -exec ls -ld ; >output
is the same asfind -exec ls -ld >output ;
or>output find -exec ls -ld ;
â ilkkachu
Aug 13 at 17:03
add a comment |Â
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
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
answered Aug 13 at 15:00
tripleee
4,84911626
4,84911626
well yeah, the redirections don't take effect just for the command started byfind -exec
, but for the wholefind
. But it doesn't matter where in the command line the redirections are set: writingfind -exec ls -ld ; >output
is the same asfind -exec ls -ld >output ;
or>output find -exec ls -ld ;
â ilkkachu
Aug 13 at 17:03
add a comment |Â
well yeah, the redirections don't take effect just for the command started byfind -exec
, but for the wholefind
. But it doesn't matter where in the command line the redirections are set: writingfind -exec ls -ld ; >output
is the same asfind -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
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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