File size: 483 Bytes
c040012
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/bash

path="/software/users/msinha/share/sd/Final_Submission/results"

str="-"

declare -A dir_cr_times

for dir in "$path"/*/;
do
  if [ -d "$dir" ] && [[ "$dir" == *"$str"* ]] ; then
    cr_time=$(stat -c %Y "$dir")
    dir_cr_times["$dir"]=$cr_time
  fi
done

sorted_dirs=($(for dir in "${!dir_cr_times[@]}"; do
  echo "$dir_cr_times[$dir]"
done | sort -n -r -k2 | awk '{print $1}'))

for dir in "${sorted_dirs[@]}"; do
  d_p=${dir%"]"}
  d_p=${d_p#"["}
  echo ${d_p}
done