I am new to Linux and am supposed to write a shell script to reorder the folders in a directory on the basis of ctime. The place where i am stuck is sorting the folders physically.
I have tried the following approaches:
- I was using combinations of ls sort command under an impression that it also changes the physical order but it is not affecting the order only listing the result.
- Using sort command alone hangs the terminal and then I am left with no other option other than canceling the command.
Kindly provide some reference for physical reordering of the folders. I have gone through articles but they were not much helpful.
What I am trying to achieve is to sort the folders in the directory on basis of last modified time. The main concern here is not how to extract time details of a folder in linux but what command can be helpful in sorting the folders physically on basis of last modified time.
Commands I have tried:
du -m --max-depth 1 | sort -rn ls -1 | sort ls -la | sort -k 1