Bash script returns different value when run from cron job than from command line
问题 I have a bash script that is intended to be run from cron. The script counts the words in document, and appends a line with the current time and the word count to a CSV file. In relevant part, the script is: EPOCH=$(date +"%s") WCC=$(wc -w ~/path/filename.txt | sed 's/\/Users\/username\/path\/filename.txt//' | sed 's/ //g') echo $EPOCH,$WCCH4 >> ~/path/wordcount-data.csv This script is run from cron with the following entry: 0 * * * * sh /Users/username/path/wordcount.sh The problem is that