For instance, if there is dir 3:
mkdir 4; cp file 4
The dir could also be called 3 other text. Still no text needs to be in mkdir 4 besides the incremented number. The highest number needs to be detected.
|
|
|
The following should do the thing in one line:
Given the folders:
this creates a folder named If you then want to copy a file named
|
|||
|
Lets assume you have sequentially numbered directories like: ' You can find the highest number (from the parent directory) by, find . -type d -name dirname\* | sed 's|dirname||' | sort -n | tail -1 So, you use the pattern in your directory names to filter it out (with ' After that, you would add one to that and proceed to make your next directory using the same pattern. Say, something like,
dirnamePattern=dirname
lastDirname=11
newDirname=$((lastDirname+1))
newDirname=${dirnamePattern}${newDirname}
will give you ' |
||||
|
|