for seqnum in $(seq -f "%03g" 1 999)
Whats wrong with:
for seqnum in {001..999}filename="~/Bureau/essai"
This assings the character "~" which is not replaced by your home directory. Your command failed because you don't have a file called "~/Bureau/essai"
Now:
filename=~/Bureau/video
You don't know what you are doing there, do you? hehehe That's a binary operator like "==" That has nothing to do with "~" being your home directory!!! The command, however, should work although not with the expected file name ;)
About these:
but this doesn't (replacing ~ with /home/user)
filename=/home/jaaf/Bureau/video #I am jaaf
index=1
mystring=${filename}${index}.mkv
ffmpeg -f alsa -ac 1 -i hw:1,0 -acodec flac -f x11grab -s $LARGEUR"x"$HAUTEUR -i :0.0+$DECALAGE_FENETRE -r 15 -vcodec libx264 -vpre lossless_ultrafast -y ${mystring}
What's the output? Could it be possible that you didnt have the "Bureau" folder?
General suggestions:
1- ALWAYS ALWAYS ALWAYS use quotes
2- use [[ instead of [
3- ALWAYS use quotes
4- don't use "break" it's bad programming style (generally) and you can do the same with a "while" and a variable to exit
5- did I mention to ALWAYS use quotes?
Regards
Marc,
thanks for the input. I tried using "for seqnum in {001..999}" in a loop and it did not work, if you can correct the syntax I would love to note it for my uses.
As for using break, I agree that it is generally bad to use it. However in this case where I was using a for loop to increment a number I was looking for something to exit the loop at the correct condition while using as few resources as possible. If you know a better was to do it while preserving the increments I would like to see it.
wow.. I think I slowly started to love scripting..
Waiting for the prblem to be solved in this case.. :-)
And Marc, ofcourse you mentioned, "ALWAYS", always ;-)
use the C style for
for (( i=0,k=0;i<10,k<1;i++ ));do
# This does what you need with the numbers
printf "%02d" $i;
# Whenever you reach the condition to exit the for loop
k=1;
done
Regards
The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.
Join / Linux Training / Board