-
-
Notifications
You must be signed in to change notification settings - Fork 85
/
sed.scroll
193 lines (178 loc) · 6.31 KB
/
sed.scroll
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
import ../code/conceptPage.scroll
id sed
name sed
appeared 1974
creators Lee E. McMahon
tags pl
tryItOnline sed
clocExtensions sed
fileType text
documentation https://www.gnu.org/software/sed/manual/sed.html
rosettaCode http://www.rosettacode.org/wiki/Category:Sed
quineRelay sed
centralPackageRepositoryCount 0
ubuntuPackage sed
country United States
originCommunity Bell Telephone Laboratories
pygmentsHighlighter Sed
filename textedit.py
fileExtensions sed [gs]sed
rijuRepl https://riju.codes/sed
example
s/.*/Hello, world!/
leachim6 Sed
filepath s/Sed.sed
fileExtensions sed
example
#!/usr/bin/sed -f sed.sed
c\
Hello World
q
hasIntegers true
hasLineComments true
hasComments true
wikipedia https://en.wikipedia.org/wiki/Sed
example
This is my dog, whose name is Frank.
This is my fish,
whose name is George.
This is my goat, whose name is Adam.
related c chomski perl awk unix regex grep vi-editor vim-editor
summary sed (stream editor) is a Unix utility that parses and transforms text, using a simple, compact programming language. sed was developed from 1973 to 1974 by Lee E. McMahon of Bell Labs, and is available today for most operating systems. sed was based on the scripting features of the interactive editor ed ("editor", 1971) and the earlier qed ("quick editor", 1965–66). sed was one of the earliest tools to support regular expressions, and remains in use for text processing, most notably with the substitution command. Other options for doing "stream editing" include AWK and Perl.
pageId 27163
dailyPageViews 329
created 2001
backlinksCount 486
revisionCount 750
appeared 1974
hopl https://hopl.info/showlanguage.prx?exp=782
tiobe sed
githubBigQuery sed
repos 1075
users 998
linguistGrammarRepo https://github.com/Alhadis/language-sed
firstCommit 2018
lastCommit 2018
committerCount 1
commitCount 31
sampleCount 1
example
# Towers of Hanoi in sed.
#
# @(#)hanoi.sed 8.1 (Berkeley) 6/6/93
# $FreeBSD$
#
#
# Ex:
# Run "sed -f hanoi.sed", and enter:
#
# :abcd: : :<CR>
#
# note -- TWO carriage returns were once required, this will output the
# sequence of states involved in moving 4 rings, the largest called "a" and
# the smallest called "d", from the first to the second of three towers, so
# that the rings on any tower at any time are in descending order of size.
# You can start with a different arrangement and a different number of rings,
# say :ce:b:ax: and it will give the shortest procedure for moving them all
# to the middle tower. The rules are: the names of the rings must all be
# lower-case letters, they must be input within 3 fields (representing the
# towers) and delimited by 4 colons, such that the letters within each field
# are in alphabetical order (i.e. rings are in descending order of size).
#
# For the benefit of anyone who wants to figure out the script, an "internal"
# line of the form
# b:0abx:1a2b3 :2 :3x2
# has the following meaning: the material after the three markers :1, :2,
# and :3 represents the three towers; in this case the current set-up is
# ":ab : :x :". The numbers after a, b and x in these fields indicate
# that the next time it gets a chance, it will move a to tower 2, move b
# to tower 3, and move x to tower 2. The string after :0 just keeps track
# of the alphabetical order of the names of the rings. The b at the
# beginning means that it is now dealing with ring b (either about to move
# it, or re-evaluating where it should next be moved to).
#
# Although this version is "limited" to 26 rings because of the size of the
# alphabet, one could write a script using the same idea in which the rings
# were represented by arbitrary [strings][within][brackets], and in place of
# the built-in line of the script giving the order of the letters of the
# alphabet, it would accept from the user a line giving the ordering to be
# assumed, e.g. [ucbvax][decvax][hplabs][foo][bar].
#
# George Bergman
# Math, UC Berkeley 94720 USA
# cleaning, diagnostics
s/ *//g
/^$/d
/[^a-z:]/{a\
Illegal characters: use only a-z and ":". Try again.
d
}
/^:[a-z]*:[a-z]*:[a-z]*:$/!{a\
Incorrect format: use\
\ : string1 : string2 : string3 :<CR>\
Try again.
d
}
/\([a-z]\).*\1/{a\
Repeated letters not allowed. Try again.
d
}
# initial formatting
h
s/[a-z]/ /g
G
s/^:\( *\):\( *\):\( *\):\n:\([a-z]*\):\([a-z]*\):\([a-z]*\):$/:1\4\2\3:2\5\1\3:3\6\1\2:0/
s/[a-z]/&2/g
s/^/abcdefghijklmnopqrstuvwxyz/
:a
s/^\(.\).*\1.*/&\1/
s/.//
/^[^:]/ba
s/\([^0]*\)\(:0.*\)/\2\1:/
s/^[^0]*0\(.\)/\1&/
:b
# outputting current state without markers
h
s/.*:1/:/
s/[123]//gp
g
:c
# establishing destinations
/^\(.\).*\1:1/td
/^\(.\).*:1[^:]*\11/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\31/
/^\(.\).*:1[^:]*\12/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\33/
/^\(.\).*:1[^:]*\13/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\32/
/^\(.\).*:2[^:]*\11/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\33/
/^\(.\).*:2[^:]*\12/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\32/
/^\(.\).*:2[^:]*\13/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\31/
/^\(.\).*:3[^:]*\11/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\32/
/^\(.\).*:3[^:]*\12/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\31/
/^\(.\).*:3[^:]*\13/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\33/
bc
# iterate back to find smallest out-of-place ring
:d
s/^\(.\)\(:0[^:]*\([^:]\)\1.*:\([123]\)[^:]*\1\)\4/\3\2\4/
td
# move said ring (right, resp. left)
s/^\(.\)\(.*\)\1\([23]\)\(.*:\3[^ ]*\) /\1\2 \4\1\3/
s/^\(.\)\(.*:\([12]\)[^ ]*\) \(.*\)\1\3/\1\2\1\3\4 /
tb
s/.*/Done! Try another, or end with ^D./p
d
isbndb 6
year|publisher|title|authors|isbn13
1997|O'Reilly Media|sed & awk|Dougherty, Dale and Robbins, Arnold|9781565922259
2002|O'Reilly Media|Sed and Awk: Pocket Reference, 2nd Edition |Arnold Robbins|9780596003524
19970301|O'Reilly Media, Inc.|sed & awk|Dale Dougherty; Arnold Robbins|9781449396602
19970301|O'Reilly Media, Inc.|sed & awk|Dale Dougherty; Arnold Robbins|9781449301880
20020612|O'Reilly Media, Inc.|sed and awk Pocket Reference|Arnold Robbins|9780596552022
20020612|O'Reilly Media, Inc.|sed and awk Pocket Reference|Arnold Robbins|9780596529024
githubLanguage sed
fileExtensions sed
trendingProjectsCount 0
type programming
interpreters gsed minised sed ssed
aceMode text
tmScope source.sed
repos 322
semanticScholar 0