Review your favorite Linux distribution.
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, 04:55 AM   #1
Registered: Feb 2011
Distribution: Centos 7
Posts: 693

Rep: Reputation: 69
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, 04:58 AM   #2
Registered: Feb 2011
Distribution: Centos 7
Posts: 693

Original Poster
Rep: Reputation: 69
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, 05:21 AM   #3
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 982
Blog Entries: 2

Rep: Reputation: 244Reputation: 244Reputation: 244
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 10:18 PM
basic html question - download link to files on my webpage question Davno Linux - Server 5 12-25-2009 08:24 AM
basic sed help needed davimint Programming 6 02-11-2008 10:06 AM
[sed] "Advanced" sed question(s) G00fy Programming 2 03-20-2006 01:34 AM
*very* basic c question usernamed Programming 9 08-21-2003 09:29 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:35 AM.

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