LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   basic sed question (https://www.linuxquestions.org/questions/linux-newbie-8/basic-sed-question-4175544650/)

vincix 06-06-2015 03:55 AM

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?

vincix 06-06-2015 03:58 AM

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.

linosaurusroot 06-06-2015 04:21 AM

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



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