Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: copying files with shell built in functions?

On Fri, Mar 28, 2003 at 05:59:29PM +0100, Dominik Vogt wrote:
>   $ while read <options> X; do echo <options> "$X"; done < ifile > ofile
> and
>   $ echo $(< ifile) > ofile

bash can't handle '\0', so forget it.

If you have zsh 4, you probably have a mapfile module.

zmodload zsh/mapfile
print -rn -- $mapfile[ifile] > ofile

Also note the zsh/files modules which provides builtin

If you don't have modules (or can't load them anymore because
your libc is gone), you should still be able to do :

while IFS= read -r line; do
  print -r -- $line
done < ifile > ofile

You'll probably end-up with a trailing \n, but that shouldn't

But I'm surprises you don't have at least one statically linked
ln or mv somewhere.

Here, I have a statically linked /sbin/zsh with mapfile and
files built in. That can reveal useful.

Also note the "vared mapfile[somefile]" for a text editor.


Messages sorted by: Reverse Date, Date, Thread, Author