The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
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

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 06-02-2005
Registered User
 

Join Date: Apr 2004
Posts: 31
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
Reply With Quote
Forum Sponsor
  #2  
Old 06-02-2005
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,667
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
Reply With Quote
  #3  
Old 06-02-2005
Registered User
 

Join Date: Apr 2004
Posts: 31
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
Reply With Quote
  #4  
Old 06-02-2005
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,667
p=print
q=quit
Reply With Quote
  #5  
Old 06-16-2005
Registered User
 

Join Date: May 2005
Posts: 80
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
Reply With Quote
  #6  
Old 06-16-2005
Registered User
 

Join Date: Feb 2005
Location: Coimbatore, Tamilnadu, India
Posts: 119
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
Reply With Quote
  #7  
Old 06-17-2005
Registered User
 

Join Date: May 2005
Posts: 31
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".
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 05:02 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0