Searching for data on a specific line numbers

Hi,
I have a file on windows and have some unix utilitties available on windows. This file is very large and have over 5 million record. I am not able to open this file in Window Editor. I am trying to see bad data on a specific lines. I just have line numbers that has bad data. I need to see the data at that line number.
I am trying to see data let say on line 411108. I tried tail -n 411108 filename but it shows last 411108 lines instead of data on line 411108. I have tried grep and head command but it returns thousands of rows. I installed VIM on windows and tried opening the file but it only clocks for hours and does not open file. I had to kill the job.

Is there a unix command that I can use to view specific data at a certain line number. I also have sed and gawk utility available on windows.

Will appreciate any help....

Thanks
Raj

sed -n '411108p' < datafile
will do it. However after printing the line, sed will continue to read until end of file. So this may be faster:
sed -n '411108p;411109q' < datafile

Thanks a lot for a quick reply.This worked.
Just curious to know the significance of "p" and "q" in the sed command below.
sed -n 411108p;411109q < datafile

If I remove the "p" and "q" the sed errors out.

Thanks
Raj

p=print
q=quit

Hi all

I have a file jh that contains :-
1
2
3
4

I use have a script as follows :-
#!/usr/bin/ksh
F1=jh
y=1
z=1

FS1=`cat $F1 | wc -l`

while [ $y -le $FS1 ]
do
set -xv
z=`expr $y + 1`
st=$y"p"
ed=$z"q"
V1=`sed -n \'$st\;$ed\' \< $F1`
echo $y
y=`expr $y + 1`
read a
done

When I execute this, I get the following result.
+ + expr 1 + 1
z=2
+ st=1p
+ ed=2q
+ + sed -n '1p;2q' < jh
sed: 0602-403 '1p;2q' is not a recognized function.
V1=
+ echo 1
1
+ + expr 1 + 1
y=2
+ read a

Can anyone tell me what is wrong ?

Thx

J

You can make as,

#!/usr/bin/ksh
F1=jh
y=1
z=1

FS1=`cat $F1 | wc -l`

while [ $y -le $FS1 ]
do
set -xv
z=`expr $y + 1`
st=$y"p"
ed=$z"q"
V1=`sed -n $st\;{$ed\;} < $F1`

echo $y
y=`expr $y + 1`
read a
done

You could use the tail command. But to get lines counted from the beginning of the file specify the line number with the '+' sign:
tail -n +123456789 myfile.
To get just one line pipe it to "head -1".

Yes, i can: the problem is your following line:

V1=`sed -n \'$st\;$ed\' \< $F1`

Presumably i would work with a generous dose "eval"-statements, because the problem is: the shell is aware of what a parameter to a command is and per definitionem an expanded variable is such a parameter. Therefore you don't need the single quotes one usually encloses his sed-statements in. Here is a basic alternative to your script which works as a pipeline filter:

#!/bin/ksh

typeset -i iBegin=$1
typeset -i iEnd=$1
typeset    chSedCmd=""

(( iEnd += 1 ))
chSedCmd="${iBegin}p;${iEnd}q"

sed -n $chSedCmd

exit 0

use with "cat <file> | <scriptname> <number>" where "<number>" is the number you want to display. My first take was:

chSedCmd="\'${iBegin}p;${iEnd}q\'"

and it produced the same error as your script: "function ... can not be parsed". The same happened with

chSedCmd="'${iBegin}p;${iEnd}q'"

When I removed the single quotes from the string it worked.

Hope this helps.

bakunin

Instead of
V1=`sed -n \'$st\;$ed\' \< $F1`

Use following syntax :
V1=`sed -n "$st;$ed" $F1`

It should work.