EDIT: SOLUTION POSTED BELOW.
So the script i wrote to check the file time stamps against the terminal time stamp, has a problem. The more I think about it, the more tedious it seems!
I have this so far
Code:
#!/bin/bash
bashts=$(ls -l /bin/bash | awk '{print $7}' | sed 's/\://g');
readarray array < <(ls -l | awk '{ print $7" "$8}';
echo "${array[@]}" | sed -e 's/\://g; s/^[ \t]*//');
for i in "${array[@]}"; do
if [[ "$i" > "$bashts" ]] ; then
echo $i | grep -v "~" | awk '{print $2}';
fi
done
exit 0
The problem is that if a file modified in n ascending folder(a dir inside a dir), it will list the folder instead of the files that have been modified since opening the shell.
How could I go about this?? I figure for starters, I could check the results with file --mime and if it returns as a directory, i could go from there. This parses file --mime for the word directory ->
file --mime dirName | sed -e 's/[-;]/ /g' | awk '{print $3}'
I am not asking how to do this. I can do it but it would be choppy. I want to know what the most efficient way of going about this is!
Thanks.
EDIT: I was initially going to put the end results in another array and run everything again that applies to directories but that seems a bit unnecessary!
The check for all files being a directory or not
Code:
readarray -t files < <(ls);
for i in "${files[@]}"; do
chk=$(file --mime $i | sed -e 's/[-;]/ /g' | awk '{print $3}');
if [[ "$chk" == "directory" ]] ; then
echo -e "$i is a dir";
fi
done
I just cant seem to think of any way to integrate that in the existing code without the use of the additional array. Hopefully someone view will have a suggestion.