Answer the question
In order to leave comments, you need to log in
How to save files in bash to a directory with a serial number?
Can you please tell me how to correctly output files to a directory in a sh script, giving them names like file000001, file000002, file000003, etc.?
Adjusted for the fact that the script can start its work at any moment and not know which file is currently the last ..005th or ..505th.
* the script takes snapshots from the rtsp stream using ffmpeg, but this does not play a special role
Answer the question
In order to leave comments, you need to log in
find . -name "file*.txt" | sort -r | head -n 1 | sed -e "s/[^0-9]//g" | read data; data=$((data + 1)); printf "file%05d.txt" "$data"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question