Jump to content

Talk:Remove lines from a file: Difference between revisions

(the intent is to make revisions to the file on disk.)
Line 5:
 
::With regards to the buffer thingy, the intent is to make revisions to the file on disk. I'm still pondering over this one, because some languages handle the buffering, leaving it as a file operation from a programming perspective. There is an excellent Unix shell solution that makes use of ed. I haven't pasted this yet though, because it is lost in my head somewhere :), but when I remember it will appear. Some languages offer "random access" to files. These might also be a good method for achieving this goal using deletion, shuffle and truncation. The task is in its early draft stages at the moment, so this gives us a chance to evolve things. [[User:Markhobley|Markhobley]] 06:23, 13 July 2011 (UTC)
 
==Argument order==
How about specifically ''not'' setting the order of arguments? This would allow the creation of a program that by default did one thing, but could be given options to remove specified options from a file.
 
Woops, I've thought of something that is close to this. What do you think about creating a command line utility "extract" that by default extracted the first line from a file and printed it to stdout whilst leaving the file behind with its first line missing. extract could be given two options: a starting line (defaults to 1), and the number of (this and subsequent), lines to extract (defaults to 1). Missing lines return the null string (without a line terminator). If the file ends without a line terminator then the if that line is returned then it is without a line terminator. Numeric options should not be zero or negative. --[[User:Paddy3118|Paddy3118]] 06:55, 13 July 2011 (UTC)
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.