OT: bash script - unexpected exit

Hiisi hiisi at fedoraproject.org
Mon Jan 23 18:14:45 UTC 2012


On 17 January 2012 19:03, Matthew Mosesohn <mmosesoh at redhat.com> wrote:
> Sorry about that.  I meant to say that using for line in $(cat file) is bad
> because it might not split up into lines properly.
> ________________________________
> From: "JD" <jd1008 at gmail.com>
>
> To: "Community support for Fedora users" <users at lists.fedoraproject.org>
> Sent: Monday, January 16, 2012 3:34:37 PM
>
> Subject: Re: OT: bash script - unexpected exit
>
> On Mon, Jan 16, 2012 at 1:25 PM, Andre Speelmans <fedora-list at cosiso.nl>
> wrote:
>> On Mon, Jan 16, 2012 at 8:55 PM, JD <jd1008 at gmail.com> wrote:
>>> What exactly were you trying to accomplish using cat?
>>
>> I was not trying, the OP had a script that did a:
>> cat file | while read line; do something done
>>
>> Matthew commented that you should not rely on cat for reading a file
>> line by line and I was curious as to why not. The example Matthe gave:
>>
>> while read; do something; done < file
>>
>> would have been my preferred way, but I was curious as to whether
>> there was a specific reason to not rely on cat. So far cat always gave
>> me the contents of the file, after all, and as such seemed pretty
>> reliable.
>>
>>
>> --
>> Regards,
>>
>> André
>>
>
> I see! Thanx for elucidating.
>
> The second method you state should be like this
>
> while read line; do
> Something with "$line"
> done < file
>
> Cheers,
>
> JD
> --

Hello, friends!
I have been busy lately preparing my PhD defending procedure. Thanks
you all for your valuable tips. Appreciate it!
-- 
Hiisi.
Registered Linux User #487982. Be counted at: http://counter.li.org/
--
Spandex is a privilege, not a right.


More information about the users mailing list