Sample Header Ad - 728x90

how to create a directory that already exists with another name

-2 votes
1 answer
890 views
i want to create directory called "A" inside my home directory but i don't know if such a directory already exists. i want to write a command that creates the directory if it does not exist. But, if the directory exists the command will create a new directory with the same name with a small addition that changes the name of the directory. The small addition should be random - that is, each time the command is run, a different addition will be received. For example, instead of "A" the command will create directory "A15" or "A7" or any such addition. It can be assumed that the new directory with the addition does not exist. The command will print the message !DONE in case the original directory "A" does not exist and it is created successfully or the message Directory exists. A new one has been created A05 where A05 is the new name
Asked by bara (19 rep)
Jan 19, 2023, 03:47 PM
Last activity: Jan 20, 2023, 10:27 AM