[GAP Forum] question about strings
Frank Heckenbach
f.heckenbach at fh-soft.de
Sat May 26 01:02:27 BST 2007
Justin C. Walker wrote:
> On May 24, 2007, at 08:47 , Joao Araujo wrote:
>
> > 1. the original files are very very big. It might take hours to
> > reach the end of the file using the scroll of nano or pico. So I
> > have been transfering the files to a Windows machine and use a word
> > processor to
> > reach the end (and put ";; ). Then send the file back to the unix
> > machine.
>
> Sheesh...you're working pretty hard to get these two characters in
> there...
>
> Your best bet is to write a small C program to do the job:
> main(...)
> {
> fd = open(...);
> lseek(fd, 0, SEEK_END);
> write(fd, ";;\n", 3);
> }
>
> That, obviously, has not been compiled or tested :-}, nor is there
> any error-checking. It will beat the pants off the "scroll to the
> end and type ';;'" process, though.
>
> There may even be Perl or Pythonic ways of doing the same thing.
> Look for "seek" or "append" methods in these scripting languages. In
> essence, you want to seek to the end of the file, write the two
> characters there, and close the file.
Though a bit OT here, the simplest way in Unix requires neither C,
Perl, Python nor a text editor. The shell with its built-in "echo"
command does it just fine (and very quickly):
echo -n ";;" >> filename
Frank Heckenbach
--
Frank Heckenbach, heckenb at mi.uni-erlangen.de
http://www.mi.uni-erlangen.de/~heckenb/
GnuPG and PGP keys: http://fjf.gnu.de/plan (7977168E)
More information about the Forum
mailing list