mirror of
https://github.com/ebrandi/FDD-book.git
synced 2026-12-06 08:33:30 +00:00
Organize companion code and materials by book part: part-01/ Foundations part-02/ Kernel & driver fundamentals part-03/ Character & block devices part-04/ Networking & storage part-05/ Buses & advanced topics part-06/ Debugging & performance part-07/ Real-world drivers appendices/ Supplementary material README.md Overview and build instructions
21 lines
545 B
Bash
21 lines
545 B
Bash
#!/bin/sh
|
|
# list_files.sh - count files in home directory
|
|
#
|
|
# DELIBERATELY NAIVE: this version is the "naive approach that breaks"
|
|
# in the chapter's "Shell Portability" section. It counts a file with
|
|
# a newline in its name as two separate files. Compare with the
|
|
# _bash, _posix, and _exec variants in this directory.
|
|
|
|
set -eu
|
|
cd "${HOME}"
|
|
|
|
count=0
|
|
while IFS= read -r f; do
|
|
fname=${f#./}
|
|
echo "File found: '$fname'"
|
|
count=$((count + 1))
|
|
done << EOF
|
|
$(find . -maxdepth 1 -type f ! -name ".*" -print)
|
|
EOF
|
|
|
|
echo "Total files found: $count"
|