Re: bash: how to echo files to text file with new line

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Mike Hoy
Date:  
To: Main PLUG discussion list
Subject: Re: bash: how to echo files to text file with new line
Thanks James.

On Sat, Nov 22, 2008 at 7:07 AM, James Mcphee <> wrote:
> for i in $( ls *.mp3 )
> do
> echo $i >> music_file
> done
>
> On Sat, Nov 22, 2008 at 6:16 AM, Mike Hoy <> wrote:
>>
>> I'm trying to write a python program that uses bash to make and use a
>> text file based on the contents of a directory. Simply put I just want
>> the text file to appear like this:
>>
>> 1.mp3
>> 2.mp3
>> 3.mp3
>>
>> and so on.
>>
>> I've tried:
>>
>> echo *.mp3 > music_file
>>
>> that puts them all in one line:
>> 1.mp3 2.mp3 3.mp3 and so on
>>
>> I know you are supposed to use \n for new lines, but can't seem to get
>> it to work in command line. Can somebody explain to me how to do it?
>>
>> echo \n *.mp3 > music_file results in
>>
>> n 1.mp3 2.mp3 and so on
>>
>> if I enclose \n in quotes it just prints:
>> \n 1.mp3 2.mp3 and so on
>>
>> Any help appreciated.
>> ---------------------------------------------------
>> PLUG-discuss mailing list -
>> To subscribe, unsubscribe, or to change your mail settings:
>> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
>
>
>
> --
> James McPhee
>
>
> ---------------------------------------------------
> PLUG-discuss mailing list -
> To subscribe, unsubscribe, or to change your mail settings:
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
>




--
Mike Hoy
---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change your mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss