Skip to content

Instantly share code, notes, and snippets.

@mikerodionov
Created March 15, 2023 16:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikerodionov/d6023bc8d6e97bb72410e45447aa6510 to your computer and use it in GitHub Desktop.
Save mikerodionov/d6023bc8d6e97bb72410e45447aa6510 to your computer and use it in GitHub Desktop.
Check Files For Empty Lines
# This scripts goes over *.txt files within specified dir
# It stops and returns exit code 1 as soon as it finds empty line within a file
# In no empty lines found exit code 0 is returned
# You can use "echo $?" command to view exit code post sh script execution
cd $dir
for f in *.txt; do
perl -lne 'exit 1 if(/^$/)' $f
if [[ $? == 1 ]]; then
echo "Inside of the loop"
exit 1
break
fi
done
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment