So I wanted to make a script in shell that when executed, either modifies a file or echoes back a message.
Here is what I managed to write:
#!/bin/bash
current=$(date +%s)
last_modified='stat -c "Y" $/home/userr/textfile'
if
[ $((current-last_modified)) -gt 120 ]; then
touch /home/userr/textfile;
else
echo "File was modified less than 2 minutes ago";
fi
ShellCheck says everything is okay, but when I try to execute it it says:
stat -c "Y" $/home/userr/textfile: syntax error: invalid arithmetic operator (error token is ""Y" $/home/userr/textfile")
Any idea where I do go wrong? Thank you in advance!