Sometimes when building software, I’d like an AI to look at the underlying libraries I’m using so we can understand the environment.
I’ve found this quick command using standard Linux utilities helpful: it takes the contents of every file in the current working directory, including subdirectories, and combines them into a single text file.
find . -type f ! -name 'combined_output.txt' ! -name '.png' ! -name '.css' -print0 | xargs -0 -I {} sh -c 'echo "Full path: {}"; echo "-------------------"; cat "{}"; printf "\n-------------------\n"' > combined_output.txt
It currently excludes files with .png and .css extensions; adjust to taste (ChatGPT can help).
Demo:
ubuntu@ubuntu:~/test$ echo "hello" > root_level_file.py
ubuntu@ubuntu:~/test$ echo "hello from inside" > subdir/child_level_file.js
ubuntu@ubuntu:~/test$ find . -type f ! -name 'combined_output.txt' ! -name '.png' ! -name '.css' -print0 | xargs -0 -I {} sh -c 'echo "Full path: {}"; echo "-------------------"; cat "{}"; printf "\n-------------------\n"' > combined_output.txt
ubuntu@ubuntu:~/test$ cat combined_output.txt
Full path: ./subdir/child_level_file.js
-------------------
hello from inside
-------------------
Full path: ./root_level_file.py
-------------------
hello
-------------------
Me, elsewhere: https://twitter.com/firasd • https://www.linkedin.com/in/firasd
