LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 06-06-2015, 04:55 AM   #1
vincix
Member
 
Registered: Feb 2011
Distribution: Centos 6.7, 7
Posts: 514

Rep: Reputation: 48
basic sed question


I was reading this tutorial on SED (http://www.grymoire.com/Unix/Sed.html#uh-0) 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
vincix
Member
 
Registered: Feb 2011
Distribution: Centos 6.7, 7
Posts: 514

Original Poster
Rep: Reputation: 48
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
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 979
Blog Entries: 2

Rep: Reputation: 235Reputation: 235Reputation: 235
Code:
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.
  


Reply


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


All times are GMT -5. The time now is 12:40 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration