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

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 04-03-2008
gator76 gator76 is offline
Registered User
  
 

Join Date: Aug 2006
Posts: 3
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.
  #2 (permalink)  
Old 04-03-2008
in2nix4life's Avatar
in2nix4life in2nix4life is offline
Registered User
  
 

Join Date: Oct 2007
Location: East Coast
Posts: 58
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.
Sponsored Links
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 12:05 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