From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FORGED_GMAIL_RCVD,FREEMAIL_FROM,HTML_MESSAGE, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 14729 invoked from network); 5 Aug 2021 16:16:24 -0000 Received: from tb-ob20.topicbox.com (173.228.157.66) by inbox.vuxu.org with ESMTPUTF8; 5 Aug 2021 16:16:24 -0000 Received: from tb-mx0.topicbox.com (tb-mx0.nyi.icgroup.com [10.90.30.73]) by tb-ob20.topicbox.com (Postfix) with ESMTP id 715D518756 for ; Thu, 5 Aug 2021 12:16:22 -0400 (EDT) (envelope-from bounce.mM5318338af59b6b616cd4210c.r522be890-2105-11eb-b15e-8d699134e1fa@9fans.bounce.topicbox.com) Received: by tb-mx0.topicbox.com (Postfix, from userid 1132) id 572423062758; Thu, 5 Aug 2021 12:16:22 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=9fans.net; h=from:to :message-id:date:mime-version:content-type :content-transfer-encoding:list-help:list-id:list-post :list-subscribe:reply-to:subject:list-unsubscribe; s=dkim-1; bh= sLBHPTGIHwXVobAEGvQ5UfOqSJgwNl0q3h0SloLWvTA=; b=BtiNneuquS+sTmvC iUpPjjvwWw0YEf8vhZ3ElgtSH/Pc1RRh1W2gQtnftMNQHvQe8z/edSpFnZ0dFEgU aSYyWmwNIIuFCoadZi9pgkvgUd3XX05z0DrnaJj+8xFMM4BHvFDXS+35o4uu1AHy GI5WAjtU39/1xsc8Zl8szffyrOc= From: revcomninos@gmail.com To: 9fans <9fans@9fans.net> Message-Id: <16281801770.A20Ab.35592@composer.9fans.topicbox.com> Date: Thu, 5 Aug 2021 12:16:17 -0400 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="16281801771.dcdD28e9C.35592" Content-Transfer-Encoding: 7bit Topicbox-Policy-Reasoning: allow: sender is a member Topicbox-Message-UUID: 76b46498-f608-11eb-9a04-11099134e1fa Archived-At: =?UTF-8?B?PGh0dHBzOi8vOWZhbnMudG9waWNib3guY29tL2dyb3Vwcy85?= =?UTF-8?B?ZmFucy9UYzJlYmVhNmJmZWYyNjA3My1NNTMxODMzOGFmNTliNmI2MTZjZDQy?= =?UTF-8?B?MTBjPg==?= List-Help: List-Id: "9fans" <9fans.9fans.net> List-Post: List-Software: Topicbox v0 List-Subscribe: Precedence: list Reply-To: 9fans <9fans@9fans.net> Subject: [9fans] A learners sam cheat sheet List-Unsubscribe: , Topicbox-Delivery-ID: 2:9fans:437d30aa-c441-11e9-8a57-d036212d11b0:522be890-2105-11eb-b15e-8d699134e1fa:M5318338af59b6b616cd4210c:1:TeuhjfcA3bN5IXox2woyLdrTDbydV89aNAqeGu3wo5I --16281801771.dcdD28e9C.35592 Date: Thu, 5 Aug 2021 12:16:17 -0400 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Below is my learners cheat sheet of sam commands which I am enclosing shoul= d find it helpful. I welcome any suggestions and/or corrections. These have= been put together mostly from the standard resources, but there are gaps i= n my knowledge.=C2=A0 $ - end of line/file $-/vi/ -- search from end of the file backwards 0,$ t "peter.c" 0 -- copy dot from 1 file to another 0 send dot to stdin of command ,|sort -- sort the file , > spell -- check spelling # substitute #'th tagged pattern ,t "junk.c" 0 -- copy current file to start of junk.c |tr a-z A-Z -- change case ,| uniq -- delete juxtaposed duplicates blank lines /vi/+- m 0 moves the line containing "vi" to the top of the file /vi/ or +/vi/ -- search forward /vi/+- t 0 copies the next line with vi to the top of the file /vi/+/vi/ -- search for the second occurrence of "vi" following dot v/regexp/ command -- If dot does not contain, run command ,>wc -l -- count lines in file ,>wc -- word count of current document w writes the whole file to disk or parts of a file x/$^/!# -- comment a line ,x/ +$/d .x/'+$/i/ --color-auto/ x/$^/!# ,x/^$\n/d x/$^/!# ,x/[0-9]/d x/^/.,/0d -- strip C comments from selection ,x/^/a/ / -- indents blocks of text with a tab stop. ,x/[a-zA-Z0-9]+/-#0;+#1| tr a-z A-Z -- capitalise every word (slow) ,x/[=E2=80=98=E2=80=98=E2=80=99=E2=80=99=E2=80=9C=E2=80=9D=E2=80=98=E2=80= =99]/c/" X/\.c$/ ,x/variable/+-p -- find all uses of a variable in the C source files ,x/=E2=80=98=E2=80=98|=E2=80=99=E2=80=99/c/"/ -- change smart quotes to cur= ly x cmd - set dot and run command on each matching line ,x/=C2=A0 +/d ,x/\*/d ,x/^ +/d ,x/\*/d -- delete all asterisks ,x/^ /d -- deletes the indents X D -- remove out all up to date files ,x/^ +/d -- Remove the space at the beginning of the line ,x g/^$\n/d -- delete blank lines ,x/good/ c/bad/ ,x g/vi/p - idem ,x/^http.[^,]*?/d ,x/^http.[^,]*?/d -- search for "http...," and delete ,x/\n+/a/\n/ -- finds every occurrence of 1 or more (+) newlines (\n) and a= ppends a new line. ,x/.*\n/ g/ed/ v/red/ p -- find ed but not red ,x/(.+\n)+/ g/It was the best of times/ p ,x /.*\n/ g/vi/ p - break file into lines, if lines contain "vi, print ,x/\n\n\n+/c/\n -- idem .x/Peter/d -- search dot for 'Peter' and delete 'Peter' X/regex/b -- switch to a loaded file with a regex X/regexp/ command -- Run command on files whose menu line matches x/regexp/command - set dot and run command on each match X/\.sam$/,x/the/+-p -- search multiple files for text and print the results .x s/.*/echo "&."/ ,x s/good/bad/ ,x s/\.\.\n/g -- break sentences into new lines ,x s/\\p/\n\n/g ,x s/\\s/\n\n/g ,x//|tr a-z A-Z x/^/d -- remove 1 tab of indent from selection ,x/teh/c/the/ ,x/^TODAY$//d -- strip from all files X ,x/(.+\n)+/ g/account/p ,y/best/ x/(.+\n)+/g/It was the best of times/p Y/regexp/ command -- As X but select unmatched files y/regexp/ command -- as x but select unmatched text ,x[a-zA-Z]+/{ g/fred/ v/...../ c/jim/ g/jim/ v/..../ c/fred/ } -- swap fred for jim in file ,x/Emacs|vi/{ g/Emacs/ c/vi/ g/vi/ c/Emacs/ } Go from search results in sam window to document: ,x g//{ p } ,| ssam -f your_script As for comments in scripts, if you use ssam(1) to run them the easiest way would be starting the lines you want to be ignored with a character that isn't a sam command - this will work because ssam sends stderr to /dev= /null. ------------------------------------------ 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/Tc2ebea6bfef26073-M53183= 38af59b6b616cd4210c Delivery options: https://9fans.topicbox.com/groups/9fans/subscription --16281801771.dcdD28e9C.35592 Date: Thu, 5 Aug 2021 12:16:17 -0400 MIME-Version: 1.0 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Below is my learners cheat sheet of sam comman= ds which I am enclosing should find it helpful. I welcome any suggestions a= nd/or corrections. These have been put together mostly from the standard re= sources, but there are gaps in my knowledge. 

$ - end of line/file
$-/vi/ -- search from end of = the file backwards
0,$ t "peter.c" 0 -- copy dot = from 1 file to another
0 <date -- insert date at the top= of the file
* 0 or more
0/regexp/ locates = the first match of the expression in the file. (The form 0;// sets dot unne= cessarily.)
0/vi/+-p -- search for the string "vi"= ; and print the whole line
0/vi/ -- search from the 1st lin= e forwards
-/^/+#10 -- go to 10th column of current line
1 <date -- replace first line with date
a1= +- (a1-+) selects the line containing the end (beginning) of a1.
. any character
. | awk '!seen[$0]++' -- dele= te non-juxtaposed duplicate lines in dot
, | awk '!seen= [$0]++' -- delete non-juxtaposed duplicate lines in whole file
[a-z] class a through to z
B < echo *.org -- One= can load multiple files by using < as in:
B < grep -= l vi * will load only those files that contain the string "vi"
{} Braces group commands
< cat /home/red/b= in/lucy.id
D is the complement of B. It eradicates the file= from sam's memory but does not delete the file from disk! Without a na= me argument removes current file
double space selection -- = x/0 a/0
< echo "Hello world" -- insert ascii c= ode at the current position
, -- equivalent to 0,$
e replaces current file with one specified
f change= s the filename
f <nl? -- set the current filename to nul= l
| frm -- format selected text
g/regexp/ c= ommand -- If dot contains regexp, run command
indent select= ion 1 tab -- x/^/a/ /
. means that it is the current file
+ means the file has a window open
- means t= he file has been read by sam
* means the file is open in mo= re than one instance
' means the loaded file differs fr= om the file on disk
[ˆn] any char but n
/.+\n/ finds lines with text between lines
n gives a LIST= of files
/.*\n/ -- matches single whole lines
<= div>[nm] n or m
| pipe dot through command
= -/.PP/,/.PP/- highlight current paragraph in an nroff doc
p= -- prints contents of dot
=3D -- prints value of dot
=
.,/regexp/ extends dot.
./regexp/// finds the se= cond following occurrence of the expression
r emacs.ms is e= quivalent to <cat emacs.ms
< replace dot by stdin of = command
(re) tag pattern
r replaces dot in = the current file with the contents of the file specified
! = run the command
> send dot to stdin of command
,|sort -- sort the file
, > spell -- check spelli= ng
# substitute #'th tagged pattern
,t = "junk.c" 0 -- copy current file to start of junk.c
|tr a-z A-Z -- change case
,| uniq -- delete juxtaposed d= uplicates blank lines
/vi/+- m 0 moves the line containing = "vi" to the top of the file
/vi/ or +/vi/ -- sear= ch forward
/vi/+- t 0 copies the next line with vi to the t= op of the file
/vi/+/vi/ -- search for the second occurrenc= e of "vi" following dot
v/regexp/ command -- If d= ot does not contain, run command
,>wc -l -- count lines = in file
,>wc -- word count of current document
w writes the whole file to disk or parts of a file
x= /$^/!# -- comment a line
,x/ +$/d
.x/'+= $/i/ --color-auto/
x/$^/!# ,x/^$\n/d
x/$^/!= # ,x/[0-9]/d
x/^/.,/0d -- strip C comments from selection
,x/^/a/ / -- indents blocks of text with a tab stop.
,x/[a-zA-Z0-9]+/-#0;+#1| tr a-z A-Z -- capitalise every word (slow= )
,x/[‘‘’’“”‘&rsq= uo;]/c/"
X/\.c$/ ,x/variable/+-p -- find all uses of a= variable in the C source files
,x/‘‘|’&r= squo;/c/"/ -- change smart quotes to curly
x cmd - set= dot and run command on each matching line
,x/  +/d
,x/\*/d
,x/^ +/d
,x/\*/d -- d= elete all asterisks
,x/^ /d -- deletes the indents
X D -- remove out all up to date files
,x/^ +/d -- = Remove the space at the beginning of the line
,x g/^$\n/d -= - delete blank lines
,x/good/ c/bad/
,x g/v= i/p - idem
,x/^http.[^,]*?/d
,x/^http.[^,]*= ?/d -- search for "http...," and delete
,x/\n+/a/= \n/ -- finds every occurrence of 1 or more (+) newlines (\n) and appends a = new line.
,x/.*\n/ g/ed/ v/red/ p -- find ed but not red
,x/(.+\n)+/ g/It was the best of times/ p
,x = /.*\n/ g/vi/ p - break file into lines, if lines contain "vi, print
,x/\n\n\n+/c/\n -- idem
.x/Peter/d -- search = dot for 'Peter' and delete 'Peter'
X/regex/= b -- switch to a loaded file with a regex
X/regexp/ command= -- Run command on files whose menu line matches
x/regexp/c= ommand - set dot and run command on each match
X/\.sam$/,x/= the/+-p -- search multiple files for text and print the results
=
.x s/.*/echo "&."/
,x s/good/bad/
<= /div>
,x s/\.\.\n/g -- break sentences into new lines
,= x s/\\p/\n\n/g
,x s/\\s/\n\n/g
,x/<strin= g>/|tr a-z A-Z
x/^<tab>/d -- remove 1 tab of inden= t from selection
,x/teh/c/the/
,x/^TODAY$/&= lt;date -- replace today with output of date
,x/\\v|\\c|\\s= 1|\\q1/d
,x/vi/c/vi{TM}/ -- change vi to vi{TM}
=
,x/vi/+-p -- print lines that contain the string vi
,x= /vi//{TM}/d - find the {TM} that follows every occurrence of vi $ delete
,x/vi/x/E/c/e/ - change all the capital "E"s in &qu= ot;vi" to lower case "e"s
X/.*/,x/<cr>= /d -- strip <cr> from all files
X ,x/(.+\n)+/ g/accou= nt/p
,y/best/ x/(.+\n)+/g/It was the best of times/p
<= /div>
Y/regexp/ command -- As X but select unmatched files
<= div>y/regexp/ command -- as x but select unmatched text
,x[a-zA-Z]+/{
g/fred/ v/...../ c/jim/
g/jim/ v/..../ c/fred/
} -- swap fred for jim in f= ile
,x/Emacs|vi/{
g/Emacs/ c/vi/
g/vi/ c/Emacs/
}
Go from search resul= ts in sam window to document:
,x g/<string>/{
p
=3D
}

,| ssam -f your_script
As for comments in scripts, i= f you use ssam(1) to run them the easiest way
would be star= ting the lines you want to be ignored with a character
that= isn't a sam command - this will work because ssam sends stderr to /dev= /null.

= --16281801771.dcdD28e9C.35592--