Using MacOSX Terminal
I am trying to make a bash script that will put screenshots into a newly made directory for the day. I am able to create the directory, as well as a .txt file with the screenshot names and file extensions. I create a variable to hold the file. For some reason doing this causes cat to return the "No such file.." error.
Here is essentially my code:
archive_screenshots(){
ymdDate=$(date +%Y-%m-%d)
#[stuff to make directory, which works]
scFile="~/Desktop/sc.txt"
scDir="~/Desktop/Screenshots/$ymdDate"
#screenshots have current date in them so grep to find
ls ~/Desktop/ | grep $ymdDate | sed 's/ /\\ /g' > "$scFile"
#File gets created, and is visible in Finder
cat "$scFile"
}
The error shows as "cat: ~/Desktop/sc.txt: No such file or directory When I run "cat ~/Desktop/sc.txt" in the Terminal it displayed the file properly