Skip to content

Instantly share code, notes, and snippets.

@alivx
Last active July 10, 2023 11:23
Show Gist options
  • Save alivx/7f1c088c336e63dc17d8fffdbf2d8363 to your computer and use it in GitHub Desktop.
Save alivx/7f1c088c336e63dc17d8fffdbf2d8363 to your computer and use it in GitHub Desktop.
List file name and content
#!/bin/bash
# Predefined list of directories
dir_list=(
dirlist
)
# List of file types to exclude
exclude_list=(
"*.zip"
"*.log"
)
for dir in "${dir_list[@]}"; do
find "$dir" -type f \( ! -name "${exclude_list[0]}" \
-a ! -name "${exclude_list[1]}" \) \
-a ! -path '*/.terraform/*' \
-a ! -path '*/.git/*' \
-exec sh -c 'echo "File: {}"; echo "Content:"; cat {}' \;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment