help needed with a small shell script!

I have a scenario where i need to look for files of these kind

filename.log.0
filename.log.1

if the files are present, then no action is to be taken, if not found,
then it shud create/touch files with the same name.

so can anyone help constructing the script for me..appreciate ur help.

Win

That's an extremely vague description, with no indication of how the script knows which files to check for and create.

for N in 1 2 3 4 5
do
        [ -f /path/to/log.file.$N ] || touch /path/to/log.file.$N
done

If this doesn't do what you want, explain why.

Thanks for the prompt reply...
Like i have mentioned earlier,

I have files of these kind

filename.log.0
filename.log.1

so my script shud look for these files, if present, dont do nothing, but if not found, create the files with the above said filenames....

I hope am clear this time around...

You said all this already, this is no clearer.

Are they really named "filename.log"? Will they always be the same name? How do you get the name?

Where are they stored?

How many of them? Just 0 and 1? Or are there potentially unlimited numbers?

How would the script know when to stop?

If there are only two filenames:

for filename in "filename.log.0" "filename.log.1"
do
    if [ ! -f "$[filename}" ]
    then
           touch "${filename}"
   fi
done

Thanks for the reply..

yes the names would be the same, I have just given the names for an example..

these are log files and i might be needing a max of 3 files.

I wud try this and update...Thanks a ton :slight_smile: