Created
March 15, 2023 16:35
-
-
Save mikerodionov/d6023bc8d6e97bb72410e45447aa6510 to your computer and use it in GitHub Desktop.
Check Files For Empty Lines
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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