Tail Question

Hi All,

I notice that the below tail cannot be done.
How can i modify this code such that i can always "tail" a variable number of lines ?

set num = 100
cat filename|grep xxx| tail -$num

try:


tail -n $num somefile

"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

Hi mvijayv,

I am using csh by the way.

Hi jim mcnamara,

Looks like i can run using the below

/usr/xpg4/bin/tail -n $num somefile

but can anybody tell me what's the difference between
/usr/xpg4/bin/tail
and
/usr/bin/tail ?

The /usr/xpg4/bin/tail is a tail that confirms to the XPG4 standard (link). The /usr/bin/tail may not necessarily confirm to that.

Hi ,

Does this /usr/xpg4/bin/head -n $num exist ?