[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] Is there a construct in bash that can replace cat?
From: |
Matthew Cengia |
Subject: |
Re: [Help-bash] Is there a construct in bash that can replace cat? |
Date: |
Tue, 20 Jan 2015 10:09:50 +1100 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On 2015-01-19 17:03, Peng Yu wrote:
> Hi,
>
> I have the following toy script. Depending the option totext, I want
> to filter the input to text or to just pass the input to the output
> without changing anything. For the latter case, I use cat. But this
> involves calling the external program cat. Is there a way to do it in
> bash internally without resorting to an external program? Thanks.
cat is the quickest way to do it; doing it with bash will probably be
much slower. A first approximation of code that should work (assuming
you're just dealing with a text file), is:
while read -r; do echo "$REPLY"; done
--
Regards,
Matthew Cengia
signature.asc
Description: Digital signature