Re: OT: bash script - unexpected exit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jan 16, 2012 at 1:25 PM, Andre Speelmans <fedora-list@xxxxxxxxx> wrote:
> On Mon, Jan 16, 2012 at 8:55 PM, JD <jd1008@xxxxxxxxx> 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
-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org


[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux