Jump to content

Talk:Sed

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by 72.219.207.160 (talk) at 14:54, 17 February 2014 (Debian Sed). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

WikiProject iconComputing C‑class Low‑importance
WikiProject iconThis article is within the scope of WikiProject Computing, a collaborative effort to improve the coverage of computers, computing, and information technology on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
CThis article has been rated as C-class on Wikipedia's content assessment scale.
LowThis article has been rated as Low-importance on the project's importance scale.

Reference for claim?

Header added. —Nils von Barth (nbarth) (talk) 00:57, 13 October 2009 (UTC)[reply]

Is there a reference for the claim of the last sentence?

Sed's language does not have variables and only primitive GOTO and branching functionality; nevertheless, the language is Turing complete. --HJH

Lots of Google references to "sed turing complete" say so, and it is not unreasonable to think that it would be. Use the file as a tape, and a special reserved symbol inserted into the file to mark the head position, use replace expressions to implement the transformation rules, and GOTOs to change state.


Or just encode the state using a set of several different 'head' symbols.


While it isn't very feature rich, to say that sed has no variables I find a bit misleading. The following is an example of "variables" in sed:

$ echo -e "bear ape dog cat" | sed 's/\([a-z]*\)\ \([a-z]*\)\ \([a-z]*\)\ \([a-z]*\)/\2 \1 \4 \3/'

ape bear cat dog

and on a practical level, if you use double quotes rather than single quotes, shell variables can be used in sed. Just be mindful of "order of operations", bash syntax, for example, is very different from sed syntax. Even without the use of shell, such functions, while quickly complicated for things like calculations, this is enough to make it turing complete (consider the Turing Machine), if variables / registers are required. --199.80.142.27 (talk) 18:58, 21 May 2009 (UTC)[reply]

This may also be useful, a calculator written completely in sed: http://www.npcguild.org/~ksb/hack/math.sed --199.80.142.27 (talk) 19:03, 21 May 2009 (UTC)[reply]


Here's an example of a UTM in sed:

See this sed script (http://sed.sourceforge.net/grabbag/scripts/turing.sed) with the accompanying explanation (http://sed.sourceforge.net/grabbag/scripts/turing.txt) -- EricP 04:24, 30 November 2005 (UTC)[reply]

Cheat sheet

Header added. —Nils von Barth (nbarth) (talk) 00:57, 13 October 2009 (UTC)[reply]

I remove the "excellent" sed cheat sheet, which is constituted of copy pasted material from www.grymoire.com and the gnu manual. The author puts his copyright on this material, and fails to give credits ( and probably forgot to ask the permission from the author of the grymoire articles) even though he has been informed of this problems. —Preceding unsigned comment added by 146.124.141.250 (talk)


excellent cheat sheet is back, still no word of a permission to reproduce the content of www.grymoire.com, still no ack of copyright from the gnu sed man page. Users is spamming wikipedia with links to his websites —Preceding unsigned comment added by 146.124.141.250 (talk) 08:58, 15 November 2007 (UTC)[reply]

Primary page?

Header added. —Nils von Barth (nbarth) (talk) 00:57, 13 October 2009 (UTC)[reply]

Why is this the primary page for SED? Shouldn't the reader be redirected to the disambiguation page? Is this acronym that much more significant than the other posible uses of the initials? —Preceding unsigned comment added by 71.249.130.166 (talk) 08:51, 4 October 2007 (UTC)[reply]

The disambiguation page can be found at the top of this page. IMO this is by far the most common usage of the word. --Kompik 15:39, 4 October 2007 (UTC)[reply]

Sed not faster than Awk

Sed is not faster than AWK. Sed's "regular" expressions aren't regular (see Regular_expression, since it allows back-references. As a result, strings can not necessarily be matched in sub-exponential time.

Also, in my personal experience, gawk is faster than GNU sed for simple grep-like tasks.

Serviscope Minor 00:55, 4 December 2007 (UTC)[reply]

move history above usage, history source?

why history is in between usage and examples? i'm not sure how it can be done here, thus let this proposition here.

http://www.engin.umd.umich.edu/CIS/course.des/cis400/sed/sed.html

tells another, i.e. year 1977, timeframe about `sed` developement

Suggest page move

I think this page should be moved, possibly to SED (software), or another name, to allow the SED disambiguation page to take the SED name. There are other things referred to as SED that are much bigger than the UNIX software. For example, the flat panel display technology called SED (Surface-conduction electron-emitter display) is the main contender (along with OLED) to replace LCD and plasma displays. So SED will be up there with LCD and LED.--Lester 10:01, 4 December 2008 (UTC)[reply]

But SED already goes to the disambiguation page (and the software is called sed, not SED). --Zundark (talk) 10:11, 4 December 2008 (UTC)[reply]

Strange

Something strange happened that I do not understand: I've just added the link to Roger Chang's SED and Shell Scripts and while doing so thought that the 3. and and 4. could actually be removed since they are subpages of the first link, but I didn't do it. Then after saving the page with the one added link, I looked at the revision and saw that the second link had already been removed by IP 69.106.246.15 the last time the page was changed. Now it looks as if I had reinserted it although I did not. Please take a look at the revision: it cleary states that I added two links! I know, nobody will believe me, because the revision says so, but I swear I did not insert it! It was already there when I visited the page and led to me thinking about removing it. 62.226.32.173 (talk) 16:34, 18 February 2009 (UTC)[reply]

You are somehow reading the revision history incorrectly. It shows that you added only one link (the Roger Chang one), and made some inconsequential whitespace change to another link. It also shows that 69.106.246.15 removed a category, not a link.
I think a number of external links in this article (including the one you added) are inappropriate, and should be removed. --Zundark (talk) 16:54, 18 February 2009 (UTC)[reply]
Ah, ok then. But I do not understand why you want to remove the link I added. There isn't any better sorted sed script archive I know of, and it is a valuable resource for people using or learning sed. 62.226.31.103 (talk) 14:29, 25 February 2009 (UTC)[reply]

sed / tr example is wrong

The tr command provided in the Samples section does not do the same as the corresponding sed command. The tr command removes all line breaks, exchanging them with whitespace, while the sed command removes every line break that is succeeded by a whitespace on the next line (but doesn't add extra whitespace). 192.100.124.219 (talk) 11:08, 9 July 2009 (UTC)[reply]

sure, I remove the tr example. coco (talk) —Preceding undated comment added 08:19, 30 July 2009 (UTC).[reply]

Wikibook

I’ve created a Wikibook on sed (wikibooks:sed) – many edits to the ’Pedia sed page are non-encyclopedic, providing (admittedly useful) examples which are better suited to ’Books. Hope the new book meets with approval, and feel free to move content better suited to ’Books to the book!

—Nils von Barth (nbarth) (talk) 01:00, 13 October 2009 (UTC)[reply]

The title has it all, I guess... Is it acceptable for a reference link to be in another language? This should probably go to the russian wikipedia page of "sed". Additionally, I could not see who made this change (how do I see who edited "that" part of an article?), but if someone uses "livejournal.com", please ask him at least make an intro in english. Thanks! —Preceding unsigned comment added by 85.72.161.183 (talk) 20:22, 29 November 2009 (UTC)[reply]

GNU regular expression library?

"minised was used by the GNU Project until the GNU Project wrote a new version of sed based on the new GNU regular expression library."

What's the GNU regular expression library? --Abdull (talk) 20:35, 16 February 2010 (UTC)[reply]

Can anyone verify "XML Table" example is correct?

Can anyone verify syntax in the "XML table into a CSV file" example is correct? Can anyone provide sample "XML table" input, and resulting "CSV file" output? If cannot be verified, maybe that complex example should be removed? 71.212.118.46 (talk) 05:53, 4 March 2013 (UTC)[reply]

Same question. 71.212.127.161 (talk) 02:06, 14 April 2013 (UTC)[reply]
I don't see any mistake in the syntax. The more serious problem is that it appears to be original research and makes various unstated assumptions about the input file format. For example, that it does not have a single root element and that the elements are nicely indented. I'd prefer to leave it out and put a link to sedtris in the external links section. 2001:558:6045:1D:56E:DCCB:ED9D:24EA (talk) 03:37, 4 May 2013 (UTC)[reply]
Thanks for striking the XML example. It seemed problematic as an example. I did move the sedtris example to what seems a better location in the article. 71.212.121.140 (talk) 22:03, 21 May 2013 (UTC)[reply]

SED and Exit Codes

The article does not discuss if SED sets an exit code (e.g., to indicate if the substitution happened or not) upon termination of program execution. I did find a statement in the GNU documentation (see the "External Links" section in the article), in the 'q' command description, of "The ability to return an exit code from the sed script is a GNU sed extension.", which implies other (most?) versions do not return an exit code? — Preceding unsigned comment added by Dan Aquinas (talkcontribs) 18:06, 12 June 2013 (UTC)[reply]

I am pretty sure all versions of sed return an exit code, but it has nothing to do with whether a substitution happened. The exit code is 0 if sed runs OK (does not crash), something else (usually 1) if sed crashes. For example, "sed s/xxx/yyy" has a syntax error (no trailing slash), so sed "bails out", returning 1. The exit code usage is the same as that for basically any Unix command, so it is not a big deal that the article does not discuss. As mentioned, GNU extensions allow you to specify your own exit code as part of the q or Q command. 71.212.122.128 (talk) 07:02, 15 July 2013 (UTC)[reply]

Concerns about theoretical text and language comparisons

I have some concerns about some of the recent edits in late August - early September.

First, I find the added theoretical discussion about how sed is "data-driven", and "imperative" unhelpful. I've used sed (and various programming languages) for decades. But I find the theoretical discussion confusing. So I pity the more general reader. sed is so different from mainstream programming languages such as C, perl, etc. So it's difficult to shoehorn sed into general categories. I have actually done "data-driven" programming. I disagree that it's helpful (or totally correct) to view sed as data-driven. As clearly stated in a comment, "Data-driven programming is a paradigm where the processing is controlled by values in data tables, rather than in program logic". The text processed by sed is NOT a data table. The sed script is more "program logic" than it is a "data table". Overall, to help the reader better understand sed, I think it's better to focus on what sed does, instead of potentially controversial / ambiguous theoretical discussions.

Second, I think it is best if we avoid saying "perl largely replaced sed" and other such comparative statements. These comparative statements have the potential to get into a "religious war". If the article becomes a "language comparison", there will be too much subjectivity and argument potential. sed, perl, awk, etc. are all useful. And they are rather different. I think it is a slippery slope discussing or implying which one is "better". 71.212.122.219 (talk) 21:49, 15 September 2013 (UTC)[reply]

Use v. Human Abuse

being that microsft defamed and attacked unix and linux (and still do) i don't see how they should be using poscript, sed, gimp, and the like. rape.

Debian Sed

the src.orig.tar.gz is not orig is is only the last change for pkging and some versions "were lost in fire".

late 2000's. recently N was changed so older scripts break incl. ones in published books, the changer admitted knowing this, and simply said "i think it's intuitive" as proof of need to use keys to force others to use really: shameful.

the worse thing to do to sed is changing its basis. adding features can cause scripts relying on syntax not being special to break that's acceptable for gnu (ie, gnugrep \b ok). all else. NO.

i made a nicer faster regex when i was young and the reason i never release it: it's far worse to have a better regex if it breaks software in any way.

and i do wonder if they do not know that (whoever, problematically this cannot be found, steps all over IEE posix opengroup et al)