[Help-bash] Is there a construct in bash that can replace cat?
From:
Peng Yu
Subject:
[Help-bash] Is there a construct in bash that can replace cat?
Date:
Mon, 19 Jan 2015 17:03:41 -0600
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 main.sh
#!/usr/bin/env bash
totext=x
function filter {
if [ "$totext" ]
then
col -b
else
cat
fi
}
some_program | filter
--
Regards,
Peng