I'm having an issue with pipping the results from the below script to a file. When I run the below script, nothing is written to the filecheck_output file.
#!/bin/bash
cd /var/www/html/images/
results="$(find projects -name "*.*" | sort -n)"
echo "${results}" > filecheck_output
The name of the script is filecheck. When I remove the > filecheck_output section from the end of the script and run ./filecheck > filecheck_output from the command line, the script runs and outputs the results into the filecheck_output file without any issues.
Why will the output only be redirected when I run the command from the command prompt and not from in the script?
/var/www/html/images/, or your/homedir or/usr/local/binor whereverfilecheckis being stored. It should be in/var/www/html/images/. AND be sure you're not getting a permissions error message when running as a script. Good luck.