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
ls command output in single line arsheshadri AIX 7 04-28-2008 11:50 AM
Editing last line of a file Anitha Chandran Shell Programming and Scripting 1 02-28-2008 09:18 AM
Can't Editing File in Single mode (using vi) heru_90 UNIX for Advanced & Expert Users 14 06-19-2007 05:42 AM
single line command roshanjain2 Shell Programming and Scripting 4 02-07-2007 01:33 AM
editing bash command line with vi peter.herlihy UNIX for Dummies Questions & Answers 3 09-03-2002 06:36 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-03-2008
Registered User
 

Join Date: Aug 2006
Posts: 3
Stumble this Post!
Question Single line file editing command?

Hello everyone. I have been reading a lot about the various different text editors at my disposal through Unix, but I just can't seem to close the deal for what I am trying to do. Is there a way to issue a single line command to edit a file where pattern=x, and do it non-destructively AND in-place? It is my understanding that sed does not do in-place edits, and I seem to be unable to use ed as a single-line command. Any help would be appreciated. Thank you.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 04-03-2008
in2nix4life's Avatar
Registered User
 

Join Date: Oct 2007
Location: East Coast
Posts: 44
Stumble this Post!
Not sure what kind of editing you want to do, but for simple find and replace, sed with the -i switch can perform that function in place.

sed -i.orig -e 's/pattern1/pattern2/g'

The -i.orig will make the change in the file and make a copy of the original file with the .orig extension in case you need to revert to the original file.

Hope this helps steer you in the right direction.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 06:33 PM.


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

Content Relevant URLs by vBSEO 3.2.0