[RLUG] Re: quick question
Bill Cunningham
axoibc at yahoo.com
Fri Jun 30 07:02:00 PDT 2006
Actually the tail command gives the last whatever:
#!/usr/bin/perl -w
$filename = "reallybighonknfile.sql";
#number of lines in the entire file
$count = `wc -l $filename`;
@output = `tail -l $count-300 $filename`;
#@output has the part of the file you'll need to feed whatever you want.
Oh and the "<" was to redirect the sql commands into the mysql process (with missing parameters for database and whatnot) which is what the original post asked for:
Bill Cunningham
----- Original Message ----
From: Sebastian Smith <ssmith at cse.unr.edu>
To: James Washer <washer at trlp.com>
Cc: rlug at rlug.org
Sent: Thursday, June 29, 2006 11:21:36 PM
Subject: Re: [RLUG] Re: quick question
True, but the proposed solution is less computationally complex...
assuming it actually solves the problem at hand. Bill mentioned that
his command format was probably incorrect, so you should not hold that
against him. It's the idea that counts.
On Thu, 29 Jun 2006, James Washer wrote:
> Reasonable... not quite.. that command will give you ONLY THE LAST 300 lines... There have been quite a number of reasonable solutions offered however.
>
> Further "<" syntax works with files, not command standard output
>
> On Thu, 29 Jun 2006 22:36:05 -0700 (PDT)
> Sebastian Smith <ssmith at cse.unr.edu> wrote:
>
>> Wow! It only took us two days to find a resonable solution ;)
>>
>>
>> On Thu, 29 Jun 2006, Bill Cunningham wrote:
>>
>>> I know the original question was to truncate the first 300 lines of the file but why do that when you could just solve the problem without modifying the original file at all. If the purpose is to not send the first 300 bytes to a command then simply use the tail command:
>>>
>>> tail -300 original_file
>>>
>>> So if you wanted to feed the original file to mysql you could use:
>>>
>>> mysql < tail -300 original_file
>>>
>>> ( I'm a little rusty so man tail to find the exact command.) I'm of the belief of keep it simple. Why modify the file at all?
>>>
>>> Bill Cunningham
>>>
>>> ----- Original Message ----
>>> From: P_Thorne <p_thorne at sbcglobal.net>
>>> To: rlug at rlug.org
>>> Sent: Thursday, June 29, 2006 7:08:39 PM
>>> Subject: [RLUG] Re: quick question
>>>
>>> This idea wouldn't satisfy the original premise of the thread that the
>>> file couldn't exist twice:
>>> Has anyone thought of using the shell command "split"? I have used
>>> split or csplit to vi edit small portions of very large ascii files,
>>> recombining the big file using "cat". It would probably not have been
>>> any faster than using "sed" as the original author did, but you might be
>>> able to do more complex editing.
>>>
>>>
>>> _______________________________________________
>>> RLUG mailing list
>>> RLUG at rlug.org
>>> http://lists.rlug.org/mailman/listinfo/rlug
>>>
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> RLUG mailing list
>>> RLUG at rlug.org
>>> http://lists.rlug.org/mailman/listinfo/rlug
>>>
>>
>> _______________________________________________
>> RLUG mailing list
>> RLUG at rlug.org
>> http://lists.rlug.org/mailman/listinfo/rlug
>>
>
> _______________________________________________
> RLUG mailing list
> RLUG at rlug.org
> http://lists.rlug.org/mailman/listinfo/rlug
>
_______________________________________________
RLUG mailing list
RLUG at rlug.org
http://lists.rlug.org/mailman/listinfo/rlug
More information about the RLUG
mailing list