Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 06-06-2015, 03:55 AM   #1
Registered: Feb 2011
Distribution: Centos 6.7, 7
Posts: 587

Rep: Reputation: 52
basic sed question

I was reading this tutorial on SED ( where it says that sed is line-oriented and that if you run sed 's/one/ONE/' <file, the change would only occur ONCE on a line.

The thing is, when I tested it, it changed every single occurrence on the whole line.

Why is that?
Old 06-06-2015, 03:58 AM   #2
Registered: Feb 2011
Distribution: Centos 6.7, 7
Posts: 587

Original Poster
Rep: Reputation: 52
Ah, ok, I think I know the answer. It might be related to the fact that that's a UNIX tutorial, not a Linux tutorial, and that's the default behaviour for sed in UNIX.
Old 06-06-2015, 04:21 AM   #3
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 981
Blog Entries: 2

Rep: Reputation: 235Reputation: 235Reputation: 235
df | sed 's/s/S/;q' 
FileSystem                 1K-blocks      Used Available Use% Mounted on

df | sed 's/s/S/g;q' 
FileSyStem                 1K-blockS      USed Available USe% Mounted on
1 members found this post helpful.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
[SOLVED] head -n -1 (sed -n -e '1,$-1p' is incorrect) sed question, as stupid as it could be. kaz2100 Programming 1 12-27-2011 09:18 PM
basic html question - download link to files on my webpage question Davno Linux - Server 5 12-25-2009 07:24 AM
basic sed help needed davimint Programming 6 02-11-2008 09:06 AM
[sed] "Advanced" sed question(s) G00fy Programming 2 03-20-2006 12:34 AM
*very* basic c question usernamed Programming 9 08-21-2003 08:29 AM

All times are GMT -5. The time now is 10:56 PM.

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