Home Linux Community Forums Software Command Line trouble with name increment

trouble with name increment

Link to this post 18 Jan 12

for seqnum in $(seq -f "%03g" 1 999)

Whats wrong with:

for seqnum in {001..999}

Link to this post 18 Jan 12


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"



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



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:

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?


Link to this post 18 Jan 12

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.

Link to this post 19 Jan 12

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 ;-)

Link to this post 19 Jan 12

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


Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Linux Training / Board

/** BC-056 Ameex changes to add tracking code - 2016-01-22 **/ ?>