You are not logged in.
Pages: 1
I have a lot of text files (song lyrics) that I want to put into 1 file and I created a bash script to do it, thus:
find . -name "*.txt" | while read file; do
echo -e "\n\n$file\n\n" >> ../emcsongs1a.txt
cat "$file" >> ../emcsongs1a.txt
done
exit 0
The problem is that the songs are not appended in alphabetical order. How can I achieve this? Have googled around but no help so far.
Sample results:
./in_the_image_of_god.txt
./in_the_presence_of_your_people.txt
./into_thy_presence_lord.txt
./it_is_no_secret.txt
./a_clare_benediction.txt
./a_merry_heart.txt
./a_new_commandment.txt
./a_thousand_candles.txt
Actually starts with "e" and then later went to "a" then jumps to "g" and so on. Not sure what the order is here.
Last edited by stryder (2010-12-27 09:01:42)
Offline
sort them
find . -name "*.txt" | sort | while read file; do
Offline
hmmm, looks like a simple:
find . -name "*.txt" | sort | while read file; do
does the trick. Just didn't think...
Thanks Allan.
Last edited by stryder (2010-12-27 09:02:30)
Offline
Pages: 1