10-10-2007
"set" with spaces might not work .... just use the below:
num=100
cat filename|grep xxx| tail -$num
Paste below in a file called "q"
#!/bin/ksh
num=$1
cat filename|grep xxx| tail -$num
filename contains:
xxxxxx
xxxxxx
asfasfa
xxxx
so when I run
$>q 2
It gives
xxxxxx
xxxx
Hope this helps,
V
9 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Working in HP-UX 10.20. I eventually want to write a bourne shell script to handle the following problem, but for now I am just toying with it at the command line.
Here's what I am basically trying to do:
tail -f log_X | grep n > log_Y
I am doing a tail -f on log_X . Once it sees "n", I... (6 Replies)
Discussion started by: cdunavent
6 Replies
2. Shell Programming and Scripting
I was wondering how can I do this
I have file myfile.txt
wc -l is: 5 000 000
I have to remove first 1 000 000 lines from header..
I tryed with tail -4000000 myfile.txt>newfile.txt
but it does not work...
any help?? (2 Replies)
Discussion started by: amon
2 Replies
3. Shell Programming and Scripting
Hello all,
I have search the forum and could not find an answer...Here is what I am trying to do. Every 15 minutes, a script send uptime output to a logfile (dailylog.log), that file contains lines like the one below:
11:21am up 44 days, 19:15, 1 user, load average: 0.00, 0.02, 0.03
... (7 Replies)
Discussion started by: qfwfq
7 Replies
4. Shell Programming and Scripting
I am trying to extract a particular line from a.log which keeps appending every sec and output that into a newfile b.log which should append itself with filtered data received from a.log
I tried
tail -f a.log |grep fail| tee -a b.log
nothing in b.log
tail -f a.log |grep fail >>b.log
... (4 Replies)
Discussion started by: wannalearn
4 Replies
5. Shell Programming and Scripting
Hello. I run the following command to get data from a logfile:
nawk 'BEGIN {FS="|"} {if ($6=="sonusSgxConfigurationErrorNotification") print ":" $10 ":" $11}' sonustrap.log | nawk 'BEGIN {FS=":"} {print $3 $5}'
This command is 'static' from the .log file, however I wanted tail -f this and... (3 Replies)
Discussion started by: lennys26
3 Replies
6. Shell Programming and Scripting
Hi,
I want to write a script which will tail a particular file for 15 mins and then sleep for 10 mins and again tail for 15 mins. This cycle will go on for a limited period of time.
How can i ensure that tail command will run for 15 mins before calling sleep command
Thanks (6 Replies)
Discussion started by: @bhi
6 Replies
7. Shell Programming and Scripting
I have 250 files that have 16 columns each - all numbered as follows stat.1000, stat.1001, stat.1002, stat.1003....stat.1250.
I would like to join all 250 of them together tail by tail as follows. For example
stat.1000
a b c
d e f
stat.1001
g h i
j k l
So that my output... (2 Replies)
Discussion started by: kayak
2 Replies
8. UNIX for Dummies Questions & Answers
hey guys, i'm in a unix course.. and while this is a homework question - i did put alittle effort into it. just wanted to ask before trial and error drives me nuts.
question 13 has us saving the last 30 characters of a file into another file
and question 14 has us saving the list of all the... (1 Reply)
Discussion started by: labelthief
1 Replies
9. Shell Programming and Scripting
because the tail +2 on the first line gives me the file name pomga I do not want anything like what I miss
tail +2 ejemplo.txt
ouput
==> ejemplo.txt <==
1
2
3
4
5
6
7
8
9
10 (2 Replies)
Discussion started by: tricampeon81
2 Replies
LEARN ABOUT DEBIAN
cps::governor
CPS::Governor(3pm) User Contributed Perl Documentation CPS::Governor(3pm)
NAME
"CPS::Governor" - control the iteration of the "CPS" functions
DESCRIPTION
Objects based on this abstract class are used by the "gk*" variants of the CPS functions, to control their behavior. These objects are
expected to provide a method, "again", which the functions will use to re-invoke iterations of loops, and so on. By providing a different
implementation of this method, governor objects can provide such behaviours as rate-limiting, asynchronisation or parallelism, and
integration with event-based IO frameworks.
CONSTRUCTOR
$gov = CPS::Governor->new
Must be called on a subclass which implements the "again" method. Returns a new instance of a governor object in that class.
SUBCLASS METHODS
Because this is an abstract class, instances of it can only be constructed on a subclass which implements the following methods:
$gov->again( $code, @args )
Execute the function given in the "CODE" reference $code, passing in the arguments @args. If this is going to be executed immediately, it
should be invoked using a tail-call directly by the "again" method, so that the stack does not grow arbitrarily. This can be achieved by,
for example:
@_ = @args;
goto &$code;
Alternatively, the Sub::Call::Tail may be used to apply syntactic sugar, allowing you to write instead:
use Sub::Call::Tail;
...
tail $code->( @args );
EXAMPLES
A Governor With A Time Delay
Consider the following subclass, which implements a "CPS::Governor" subclass that calls "sleep()" between every invocation.
package Governor::Sleep
use base qw( CPS::Governor );
sub new
{
my $class = shift;
my ( $delay ) = @_;
my $self = $class->SUPER::new;
$self->{delay} = $delay;
return $self;
}
sub again
{
my $self = shift;
my $code = shift;
sleep $self->{delay};
# @args are still in @_
goto &$code;
}
SEE ALSO
o Sub::Call::Tail - Tail calls for subroutines and methods
AUTHOR
Paul Evans <leonerd@leonerd.org.uk>
perl v5.14.2 2012-06-27 CPS::Governor(3pm)