![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| grep - searching for a specific string | manthasirisha | Shell Programming and Scripting | 2 | 01-05-2006 06:24 AM |
| searching text files on specific columns for duplicates | Gerry405 | UNIX for Dummies Questions & Answers | 2 | 08-18-2005 07:51 AM |
| Searching for a specific phrase on Unix server | mmcaleer | UNIX for Dummies Questions & Answers | 1 | 02-07-2005 01:18 PM |
| Can't figure out how to display specific data from a line using awk. | ctcuser | Shell Programming and Scripting | 1 | 06-24-2004 11:55 AM |
| Searching for a specific string in an argumnet | dinplant | Shell Programming and Scripting | 1 | 03-11-2002 12:28 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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
__________________
Thanks Raj |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
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 |
|
#3
|
|||
|
|||
|
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
__________________
Thanks Raj |
|
#4
|
||||
|
||||
|
p=print
q=quit |
|
#5
|
|||
|
|||
|
Problem with sed
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 |
|
#6
|
|||
|
|||
|
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 |
|
#7
|
|||
|
|||
|
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". |
|||
| Google The UNIX and Linux Forums |