GNU bug report logs -
#24007
cat: append at specific line, not end of file
Previous Next
Reported by: NAVEEN KUMAR <naveen15690 <at> gmail.com>
Date: Sat, 16 Jul 2016 15:23:02 UTC
Severity: wishlist
Tags: wontfix
Done: Assaf Gordon <assafgordon <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
tag 24007 notabug
thanks
On 07/16/2016 12:11 AM, NAVEEN KUMAR wrote:
> Hi Team,
>
> Greetings!
>
> I was sitting next my system looking for some basic code brush up and was
> playing with CAT command, and though of some kind of additional features to
> our existing CAT command, such as...
>
>
>
> *"Write a CAT command program, which will allow appending text or lines of
> code at user specified line" not only at the end of file.*
>
> *Ex: cat >> filename.c line_number *
That won't work. The >> operator in the shell opens a file in
append-only mode, and the operating system enforces that in append mode,
data can only be added at the end, not the middle.
Furthermore, what you suggested can already be done with sed, so there
is no real reason to bloat cat to add non-standard functionality that
can already be done with a standard tool.
sed "$line r $file_to_insert" $file_to_expand
inserts the contents of $file_to_insert starting at line $line of the
file $file_to_expand, and pipes the resulting concatenation to stdout.
These days, it's a very high bar to justify adding new features, and we
prefer to save additions for things that either match other
implementations or that accomplish things more efficiently than what is
possible using only standard tools. Therefore, I'm closing this feature
suggestion in the bug database as it is unlikely to be implemented, but
do feel free to add further comments on the thread.
Feature suggestions can be sent to coreutils <at> gnu.org, rather than the
bug list, if you are not sure whether it is worth pursuing, so that we
don't clog up the bug database.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[signature.asc (application/pgp-signature, attachment)]
This bug report was last modified 6 years and 286 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.