I have a file say file.txt
and contents looks like below with more than 10000 lines.
Wed May 27 15:41:29 PDT 2020
Entering directory : /aaa/bbb/ccc
Wed May 27 15:42:30 PDT 2020
Entering directory : /aaa/bbb/ccc/ddd
Wed May 27 15:43:19 PDT 2020
Entering directory : /aaa/bbb/ccc/ddd/eee
Wed May 27 15:44:25 PDT 2020
Leaving directory : /aaa/bbb/ccc/ddd/eee
Wed May 27 15:45:37 PDT 2020
Leaving directory : /aaa/bbb/ccc/ddd'
Wed May 27 15:46:42 PDT 2020
Leaving directory : /aaa/bbb/ccc
What need to done
Need to print out which directory taking how much time based on the timestamp before Entering and Leaving directory.
Output should be
_Directory_ : `/aaa/bbb/ccc`
_Time taken_ : `00:05:13`
Entering time for this directory is : Wed May 27 15:41:29 PDT 2020
and Leaving time is : Wed May 27 15:46:42 PDT 2020
So the time difference is the output.
similarly need to print both directory path and the time difference for other instance as well.
Tried searching in the forum and got this, but it didn't solve my problem fully. Though I am not a pro in shell script. So if someone could help to me get the output will be really great.
Thank You
/aaa/bbb/ccc/ddd'
supposed to be there or is it a typo? Either explain it or fix it. Are there really blank chars at the end of each line in your input? If so how do we know when a directory name ends since a directory name could have blanks at the end? Again - explain or fix.