I am trying to write a script that will report back the last time a file was updated in a folder. The folders are created everyday Example: /home/user/todaysdate. Inside todaysdate folder exsist that are created when somethng is created. So for example we will have fol1 fol2 fol3. I am trying to get a script to login to each folder and display the time of the last file created.
#!/bin/bash
folder=`date +%Y%m%d`
ssh -q server "cd /home/user/$folder/ ; bash -c "ls -la | uniq" > list.txt
This will create a list of the different folders that were made. Now I need to ssh into each folder which is where I am stuck. The output of the list.txt will be: fol1 fol2 fol3
ssh -q server "bash -c \"ls -ltr /home/user/$folder/<Need List Variable Here> | tail -1\"" awk '{print $8}
The above command gives me my time. I believe I need a while loop to ssh into the server and into the variables created in list.txt but I can't get a working on. Any help?
for LINE in $(cat list.txt) do