LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-20-2009, 07:21 PM   #1
faizlo
Member
 
Registered: Sep 2008
Location: USA
Distribution: Linux Mint Qiana
Posts: 190

Rep: Reputation: Disabled
simple sed question


Hi All,

I have been trying to use sed to make a change in my files.
I used the following command:
Code:
sed -e 's/-l 1000/-l 5000/' <old > new
but what I get is the the new files without the intended change.
I also used:
Code:
sed -i -e 's/-l 1000/-l 5000/' <old > new
but gained nothing.

I used also:
Code:
sed -i -e 's/1000/5000/' old > new
and in this case, the change took place in the old file and the new file was produced empty of any contents.

I used double quotes instead on one, and I also removed the "<" sign before the name of the old file.

Thanks in advance,

faizlo

Last edited by faizlo; 01-20-2009 at 07:27 PM.
 
Old 01-20-2009, 07:41 PM   #2
twantrd
Senior Member
 
Registered: Nov 2002
Location: CA
Distribution: redhat 7.3
Posts: 1,440

Rep: Reputation: 52
Quote:
I have been trying to use sed to make a change in my files.
You don't need to redirect to a new file if you're using -i. Just do:
Code:
sed -i 's/1000/5000/' filename
Check your file again and you will see the replacement changes.

-twantrd
 
Old 01-20-2009, 07:45 PM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,128

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
All sed questions are simple - it's the regex that can get curly ...

Looks like it should work - bash and GNU sed ?.
Else try escaping the spaces maybe. The reason the last attempt did what it did was because you told it to - look up the "-i" switch.

Last edited by syg00; 01-20-2009 at 07:48 PM.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
simple sed question jaykup Programming 3 02-25-2008 01:23 AM
Simple sed problem need help Silvermask Linux - Software 2 04-12-2007 01:15 PM
Simple question about sed or awk setianusa Programming 2 09-16-2005 03:57 PM
Simple bash/awk/sed scripting question R00ts Programming 4 04-16-2005 02:55 AM
using sed, simple question bobthebat Programming 3 04-30-2001 10:01 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:03 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration