Showing posts with label bash. Show all posts
Showing posts with label bash. Show all posts

Tuesday, August 16, 2011

Bash script to put all the info from separate files in one

So, I had this directory tree full of python scripts I've written but I wanted to put them all in one file to make it easy to read/find stuff, so I was trying to think a way to cut myself some slack, so I ended up writing this small piece of code in bash to get it done:


#!/bin/bash
for filex in $(ls *.py);do
echo "working on file: $filex"
echo -e "\n----------$filex-------------------\n" >> allTheCode.txt
cat $filex >> allTheCode.txt
echo -e "\n-----------------------------------\n" >> allTheCode.txt
done


I know this looks ugly, however it works :), if you know a better way just drop me a comment!