How to automatically add file paths like comment?
Simply try to correct and refactor the code you provided currently.
#!/bin/bash
pwd=scripts/test_copy-content
files=$(find "$pwd" -type f)
for file in $files; do
case "$file" in
*.sh|Makefile)
First-line_comment="# *$file"
;;
*.go|*.py)
First-line_comment="# *$file"
;;
*.md|*.html)
First-line_comment="<!-- *$file -->"
;;
*.css|*.js)
First-line_comment="/* *$file */"
;;
*.ico|*.jpg|*.png)
# Skip these file types
continue
;;
*)
First-line_comment="# *$file"
;;
esac
firstline=$(head -n 1 "$file")
if [[ "$firstline" != "$First-line_comment" ]]; then
echo "$First-line_comment\n$(cat "$file")" > "$file"
fi
done