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
Removing the first and last lines in a file naveendronavall Shell Programming and Scripting 2 12-30-2007 01:22 AM
Removing the first and last lines in a file naveendronavall AIX 1 12-29-2007 11:44 PM
Removing lines within a file tookers Shell Programming and Scripting 3 08-22-2006 09:49 AM
Removing lines from a file PradeepRed Shell Programming and Scripting 4 12-17-2005 06:34 AM
Removing lines in a text file. WABonnett Shell Programming and Scripting 4 11-25-2003 11:27 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 11-14-2006
computersaysno computersaysno is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 5
Removing lines from a file

I'm trying to find a command which will allow me to remove a range of lines (2-4) from a .dat file from the command line without opening the file.

Someone mentioned using the ex command?

Does anyone have any ideas?

thanks
  #2 (permalink)  
Old 11-14-2006
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,717
Code:
sed '2,4d' oldfile > newfile
mv newfile oldfile
  #3 (permalink)  
Old 11-14-2006
computersaysno computersaysno is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 5
Thank you!
  #4 (permalink)  
Old 11-14-2006
computersaysno computersaysno is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 5
Is there a way of substituting one word for another word, in the same manner?
  #5 (permalink)  
Old 11-14-2006
venu_nbk venu_nbk is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 33
After u open the File in vi editor

:s/oldword/newword/g

Does replacing old word with new one everywhere in the file.
  #6 (permalink)  
Old 11-14-2006
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,119
Quote:
Originally Posted by venu_nbk
After u open the File in vi editor

:s/oldword/newword/g

Does replacing old word with new one everywhere in the file.
no, this replaces ALL the occurances of 'oldword' to 'newword' on the CURRENT line where your cursor is.

Last edited by vgersh99; 11-14-2006 at 06:52 PM..
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 11:53 PM.


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