The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
awk print the next line on the current line ajp7701 Shell Programming and Scripting 5 05-25-2009 12:17 PM
print line whatever line i want in a file... there any way kittusri9 Shell Programming and Scripting 1 05-15-2008 12:37 PM
how to make a line BLINKING in output and also how to increase font size in output mail2sant Shell Programming and Scripting 3 04-14-2008 07:30 AM
How do i print this output all on the same line? rcon1 UNIX for Dummies Questions & Answers 1 02-05-2008 10:52 AM
Print file line by line handak9 Shell Programming and Scripting 2 10-20-2005 08:44 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-30-2005
vasikaran vasikaran is offline
Registered User
  
 

Join Date: Jun 2005
Location: india
Posts: 55
locating the line and print the output

hi all,

I would like to know , if a file contains say 100 lines, and if i want to locate the 54th line and print the output , how to do it??

for eg , if a file details.txt which contains say 100 entries like

admin ....................
rajes ....................
test ..................
welcome ....................
admins .....................
.....
....
....
...
....

I dont want to use grep command..

pls help.
  #2 (permalink)  
Old 06-30-2005
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
Code:
sed -n '54,54p' details.txt
More over

Code:
sed -n '54,56p' details.txt
will print line 54, 55 and 56

vino
  #3 (permalink)  
Old 06-30-2005
vasikaran vasikaran is offline
Registered User
  
 

Join Date: Jun 2005
Location: india
Posts: 55
thanks yaar it is working

Thats great, i have tested it, it is working
  #4 (permalink)  
Old 06-30-2005
matrixmadhan matrixmadhan is online now Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,952
hi u can try this also

awk '{if(NR == 54) print}' <filename>
  #5 (permalink)  
Old 08-03-2005
vasikaran vasikaran is offline
Registered User
  
 

Join Date: Jun 2005
Location: india
Posts: 55
cuting the entries from one file and copy to other

here i found that , i can locate the line numbers and copy to another file,

but i want the data which i had copied to another file, shd be removed from the parent file..

eg

file a has 1000 rows

sed -n '500,1000p' a >> b

b has 501 and a has 1000 still, i want file 'a' to be having 499 only

how is it possible
  #6 (permalink)  
Old 08-03-2005
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
Code:
sed -n '500,1000d' a >> a.tmp
mv a.tmp a

vino
  #7 (permalink)  
Old 08-03-2005
vasikaran vasikaran is offline
Registered User
  
 

Join Date: Jun 2005
Location: india
Posts: 55
d is not working

sed -n '500,1000d' a >> a.tmp
mv a.tmp a

d is not working,

i dont find any output in a.tmp file

pls help
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:17 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0