This script I wrote has some unexpected behavior.
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
It copies the all of the contents from the directory I run it in, to all ascending dirs that have initalized git repos in them.
What it does is compare how long I have I have had the shell open, against all files in that directory. So any file that has been modified since I have opened the shell, will be displayed to stdout.
ANYONE KNOW THE CAUSE?
What i am actually doing is writing a CL automation script for github.
I also wrote a script for a recursive touch function. It recursively touches all fles in any dir that has an initialized git repo. Then updates the terminals time stamp as well. On every reboot/boot.
Code:
#!/bin/bash
sudo touch /bin/bash
readarray -t paths < <(find ~ -iname ".git" | sed -e 's/^[.]*//; s/.git//g');
readarray -t files < <(ls -l | awk '{print $8}' | grep -v "~")
for f in "${paths[@]}"; do
cd "$f"
for i in "${files[@]}"; do
sudo touch "$i"
done
done
sudo touch /bin/bash
So I hope you can see what I am trying to accomplish and can tell my why my script is doing this copying non-sense. Thanks