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=-1.0 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2 autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 4283 invoked from network); 31 Aug 2021 06:58:36 -0000 Received: from tb-ob0.topicbox.com (64.147.108.117) by inbox.vuxu.org with ESMTPUTF8; 31 Aug 2021 06:58:36 -0000 Received: from tb-mx1.topicbox.com (tb-mx1.nyi.icgroup.com [10.90.30.61]) by tb-ob0.topicbox.com (Postfix) with ESMTP id E4BA221E2E for ; Tue, 31 Aug 2021 02:58:34 -0400 (EDT) (envelope-from bounce.mM839d78d594076ff44368770d.r522be890-2105-11eb-b15e-8d699134e1fa@9fans.bounce.topicbox.com) Received: by tb-mx1.topicbox.com (Postfix, from userid 1132) id DE9B335A868A; Tue, 31 Aug 2021 02:58:34 -0400 (EDT) ARC-Authentication-Results: i=2; topicbox.com; arc=pass; dkim=pass (2048-bit rsa key sha256) header.d=gmail.com header.i=@gmail.com header.b=IJSfQ6qm header.a=rsa-sha256 header.s=20161025 x-bits=2048; dmarc=pass policy.published-domain-policy=none policy.published-subdomain-policy=quarantine policy.applied-disposition=none policy.evaluated-disposition=none (p=none,sp=quarantine,d=none,d.eval=none) policy.policy-from=p header.from=gmail.com; spf=pass smtp.mailfrom=henesy.dev@gmail.com smtp.helo=mail-lf1-f51.google.com; x-internal-arc=fail (as.1.topicbox.com=pass, ams.1.topicbox.com=fail (body has been altered)) (Message modified while forwarding at Topicbox) ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d= topicbox.com; h=mime-version:references:in-reply-to:from:date :message-id:subject:to:content-type:content-transfer-encoding :list-help:list-id:list-post:list-subscribe:reply-to :list-unsubscribe; s=sysmsg-1; t=1630393114; bh=2IZ0BOR1GCvD5EAG EDMVlnDIYuc+qRM5fiizK/6vTZE=; b=ayG8a0Ogf0slH3SaykFNiJFdzdkcCZqh 9JwJzieOp1bAUpYFEBXfgWsbdtO0GkjPgf+5U4KfrNyHqXn/I/q8qnxxLHyg+5fa aSlLWVkjN2lHEhfThLxvxZi9AndniqJE02Mp/0TOy8zvYpK5ycXMuAoyW901OLiQ vg4cOs0Ug2M= ARC-Seal: i=2; a=rsa-sha256; cv=pass; d=topicbox.com; s=sysmsg-1; t= 1630393114; b=GDuP0pBodgyP+e2Oc7Cd/J9PzMMx4CWSW7rFNRIwG9GsX5nmm7 fot4gT7DWFtfizZbw5cs7aVOVazXf8Mfmqsj81BWy94yaZ2+c8U7A6+wQdvQm0Ml tcWkJzo6D89dusuA99gmfQOMduz5K36dOG6ulcmLRmOMie+9UDG1ZY8Qw= Authentication-Results: topicbox.com; arc=pass; dkim=pass (2048-bit rsa key sha256) header.d=gmail.com header.i=@gmail.com header.b=IJSfQ6qm header.a=rsa-sha256 header.s=20161025 x-bits=2048; dmarc=pass policy.published-domain-policy=none policy.published-subdomain-policy=quarantine policy.applied-disposition=none policy.evaluated-disposition=none (p=none,sp=quarantine,d=none,d.eval=none) policy.policy-from=p header.from=gmail.com; spf=pass smtp.mailfrom=henesy.dev@gmail.com smtp.helo=mail-lf1-f51.google.com; x-internal-arc=fail (as.1.topicbox.com=pass, ams.1.topicbox.com=fail (body has been altered)) (Message modified while forwarding at Topicbox) X-Received-Authentication-Results: tb-mx1.topicbox.com; arc=none (no signatures found); bimi=skipped (DMARC Policy is not at enforcement); dkim=pass (2048-bit rsa key sha256) header.d=gmail.com header.i=@gmail.com header.b=IJSfQ6qm header.a=rsa-sha256 header.s=20161025 x-bits=2048; dmarc=pass policy.published-domain-policy=none policy.published-subdomain-policy=quarantine policy.applied-disposition=none policy.evaluated-disposition=none (p=none,sp=quarantine,d=none,d.eval=none) policy.policy-from=p header.from=gmail.com; iprev=pass smtp.remote-ip=209.85.167.51 (mail-lf1-f51.google.com); spf=pass smtp.mailfrom=henesy.dev@gmail.com smtp.helo=mail-lf1-f51.google.com; x-aligned-from=pass (Address match); x-google-dkim=pass (2048-bit rsa key) header.d=1e100.net header.i=@1e100.net header.b=C57TXsnE; x-me-sender=none; x-ptr=pass smtp.helo=mail-lf1-f51.google.com policy.ptr=mail-lf1-f51.google.com; x-return-mx=pass header.domain=gmail.com policy.is_org=yes (MX Records found: alt4.gmail-smtp-in.l.google.com,gmail-smtp-in.l.google.com,alt1.gmail-smtp-in.l.google.com,alt3.gmail-smtp-in.l.google.com,alt2.gmail-smtp-in.l.google.com); x-return-mx=pass smtp.domain=gmail.com policy.is_org=yes (MX Records found: alt4.gmail-smtp-in.l.google.com,gmail-smtp-in.l.google.com,alt1.gmail-smtp-in.l.google.com,alt3.gmail-smtp-in.l.google.com,alt2.gmail-smtp-in.l.google.com); x-tls=pass smtp.version=TLSv1.2 smtp.cipher=ECDHE-RSA-AES256-GCM-SHA384 smtp.bits=256/256; x-vs=clean score=0 state=0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=9fans.net; h= mime-version:references:in-reply-to:from:date:message-id:subject :to:content-type:content-transfer-encoding:list-help:list-id :list-post:list-subscribe:reply-to:list-unsubscribe; s=dkim-1; bh=2IZ0BOR1GCvD5EAGEDMVlnDIYuc+qRM5fiizK/6vTZE=; b=Gxxl1PE8q39n LPOOyLi7/2qk6MnsZM1YZUE41UxQ6UszMHG+RpwuWwFhOAVHhutmnz96tIEvWgGM NsfjLoTNZYAFEYC3qrRqc2v+yY9iJshJHMKO7A5rtOs1o+BDt//92SIoZVR9bN9O JdLhe1ktrL6YhnGSbRKa23tHd3n3chw= Received: from tb-mx1.topicbox.com (localhost.local [127.0.0.1]) by tb-mx1.topicbox.com (Postfix) with ESMTP id 323FB35A8257 for <9fans@9fans.net>; Tue, 31 Aug 2021 02:58:23 -0400 (EDT) (envelope-from henesy.dev@gmail.com) Received: from tb-mx1.topicbox.com (localhost [127.0.0.1]) by tb-mx1.topicbox.com (Authentication Milter) with ESMTP id D0FCE23C8AC; Tue, 31 Aug 2021 02:58:23 -0400 ARC-Seal: i=1; a=rsa-sha256; cv=none; d=topicbox.com; s=arcseal; t= 1630393103; b=jDx7t8n22a9cWH/ZtNmvrXeHTOgEd1G8JwIWk3c3z7/8XGsodk xIOsJPZT/hgXxSFx3ZVx81KkdYE9W/l5xS3xsfb1LGnYMU/QpcYkJZD1IAZnSxSe k7i1Wq57BQtmhFr8zJigmquwSe55z6Aq2/WrSOjlEWK0jYBmKB/7hnSQ2PmgoGXo oguMR66PEe3ffDAF5g0ROD3Z77RScUMFFHJ0bIhw+f552/ejQkAfFHnLwr7iZEzC Ar4G3KjYdZkrH3+47n4xIK5CVlVRhIvox43BdvrSKDTrVdHobqRdyA7FcfrgiCMy n4Otcv2A/rOraQfHvfVY1GiUxuNZeNjeevcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= topicbox.com; h=mime-version:references:in-reply-to:from:date :message-id:subject:to:content-type:content-transfer-encoding; s=arcseal; t=1630393103; bh=fZjhZ3PCBfbf7ehnMvnWHe6kvLSlgkWgHE7 LyG7tOis=; b=WLfJ4++O7kLsuDMUt9bg4tUzC8/7GCA8ywgLQPGz7lzhhA7CMEj hsYF0TRUamWTtkfC5nWjoPasjRKpRTR8dALCLqheUWZgpGqaciVt77cGiaAYmrxU lSmgUvuPw+JTVqEKas9HiM+NRPV+aS8/aGaeXhjxklDzpkJNNPxnMe4VlGkpgsFa imFyDCOS0vj6uvsroL3nAe+s9JnnplkGWHzjluMZx6q4ifIdZGARgYQHcBQ+ybmT RfUthiw3awbu61gHRM9bjTWdTiWKi6WomippThFYk/K3QMwUPLeJQAF28AkcnBHz 2wMVbj9Zaezx9oS4pK6K+VbjASR5IGrLn3A== ARC-Authentication-Results: i=1; tb-mx1.topicbox.com; arc=none (no signatures found); bimi=skipped (DMARC Policy is not at enforcement); dkim=pass (2048-bit rsa key sha256) header.d=gmail.com header.i=@gmail.com header.b=IJSfQ6qm header.a=rsa-sha256 header.s=20161025 x-bits=2048; dmarc=pass policy.published-domain-policy=none policy.published-subdomain-policy=quarantine policy.applied-disposition=none policy.evaluated-disposition=none (p=none,sp=quarantine,d=none,d.eval=none) policy.policy-from=p header.from=gmail.com; iprev=pass smtp.remote-ip=209.85.167.51 (mail-lf1-f51.google.com); spf=pass smtp.mailfrom=henesy.dev@gmail.com smtp.helo=mail-lf1-f51.google.com; x-aligned-from=pass (Address match); x-google-dkim=pass (2048-bit rsa key) header.d=1e100.net header.i=@1e100.net header.b=C57TXsnE; x-me-sender=none; x-ptr=pass smtp.helo=mail-lf1-f51.google.com policy.ptr=mail-lf1-f51.google.com; x-return-mx=pass header.domain=gmail.com policy.is_org=yes (MX Records found: alt4.gmail-smtp-in.l.google.com,gmail-smtp-in.l.google.com,alt1.gmail-smtp-in.l.google.com,alt3.gmail-smtp-in.l.google.com,alt2.gmail-smtp-in.l.google.com); x-return-mx=pass smtp.domain=gmail.com policy.is_org=yes (MX Records found: alt4.gmail-smtp-in.l.google.com,gmail-smtp-in.l.google.com,alt1.gmail-smtp-in.l.google.com,alt3.gmail-smtp-in.l.google.com,alt2.gmail-smtp-in.l.google.com); x-tls=pass smtp.version=TLSv1.2 smtp.cipher=ECDHE-RSA-AES256-GCM-SHA384 smtp.bits=256/256; x-vs=clean score=0 state=0 X-ME-VSCause: gggruggvucftvghtrhhoucdtuddrgedvtddrudduledgheehucdltddurdegudehrddttd dmucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgf nhhsuhgsshgtrhhisggvpdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttd enucenucfjughrpeggfhgjhfffkffuvfgtgfesthhqredttddtjeenucfhrhhomhepufgv rghnucfjihhntghhvggvuceohhgvnhgvshihrdguvghvsehgmhgrihhlrdgtohhmqeenuc ggtffrrghtthgvrhhnpeefheegvdevteefkefhffegkeduieeggfeuvdffkeektefghedu vddufeehfeeiveenucffohhmrghinheplhhinhgvrdhvihdpvggthhhordhorhhgnecukf hppedvtdelrdekhedrudeijedrhedunecuvehluhhsthgvrhfuihiivgeptdenucfrrghr rghmpehinhgvthepvddtledrkeehrdduieejrdehuddphhgvlhhopehmrghilhdqlhhfud dqfhehuddrghhoohhglhgvrdgtohhmpdhmrghilhhfrhhomhepoehhvghnvghshidruggv vhesghhmrghilhdrtghomheq X-ME-VSScore: 0 X-ME-VSCategory: clean Received-SPF: pass (gmail.com ... _spf.google.com: Sender is authorized to use 'henesy.dev@gmail.com' in 'mfrom' identity (mechanism 'include:_netblocks.google.com' matched)) receiver=tb-mx1.topicbox.com; identity=mailfrom; envelope-from="henesy.dev@gmail.com"; helo=mail-lf1-f51.google.com; client-ip=209.85.167.51 Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by tb-mx1.topicbox.com (Postfix) with ESMTPS for <9fans@9fans.net>; Tue, 31 Aug 2021 02:58:22 -0400 (EDT) (envelope-from henesy.dev@gmail.com) Received: by mail-lf1-f51.google.com with SMTP id j4so36378143lfg.9 for <9fans@9fans.net>; Mon, 30 Aug 2021 23:58:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:content-transfer-encoding; bh=fZjhZ3PCBfbf7ehnMvnWHe6kvLSlgkWgHE7LyG7tOis=; b=C57TXsnEx0a0Js1Xva0JbzZWGgctuzm4SR3wz5M2TIebsaPEwhyeLFKaebwBySf7Tw HP5IAkbSlrvJujpWPlB1wNTjnjGs776+twcvfi36wfyJptQO4UktKsgYCSOklQydvu13 xt839Spb6dhvau2iBneZWl3e9H0GUoh48zje1YuoOuUAIDifB1CxRsfYg0wrO1bUUAZx qGFddUq4S6424j+1xB9nFLVd1oT/pYns2TohbRPUjyBGRWNkRPrBCjsbqGOa4SUSoBpD qWhCgEk/cZa5iyyfcylJensgwPJdC2uoVIPg08omZIHc0EUgNeY3Y3efNXp5UTHArpMa 3jrw== X-Gm-Message-State: AOAM531KT4kPMf5o61mpo08GoKJ/0tq+rzcvkIwY2+QcqM1+DeebCnHN im0PzF0da80PEkVZQYRM8S9Fn7MEK6A9THkHfZx3WKOn X-Google-Smtp-Source: ABdhPJzJvtTeE98EyB6zCwAzzXVIUvjoyYYECpj/1vnQv8z2KSbtBuCjVVCsSL8Dy0lk4bXQmO/YRvFfmvST0kfIbEU= X-Received: by 2002:ac2:44d9:: with SMTP id d25mr7132093lfm.267.1630393100810; Mon, 30 Aug 2021 23:58:20 -0700 (PDT) MIME-Version: 1.0 References: <16303891900.ad7cb5c.65212@composer.9fans.topicbox.com> In-Reply-To: <16303891900.ad7cb5c.65212@composer.9fans.topicbox.com> From: Sean Hinchee Date: Mon, 30 Aug 2021 23:58:09 -0700 Message-ID: Subject: Re: [9fans] Revised sam cheat sheat To: 9fans <9fans@9fans.net> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Topicbox-Policy-Reasoning: allow: sender is a member Topicbox-Message-UUID: d7cf82b0-0a28-11ec-9191-b27bda0d9009 Archived-At: =?UTF-8?B?PGh0dHBzOi8vOWZhbnMudG9waWNib3guY29tL2dyb3Vwcy85?= =?UTF-8?B?ZmFucy9UNWE1OWQ4YzNiNDA0YjE0ZC1NODM5ZDc4ZDU5NDA3NmZmNDQzNjg3?= =?UTF-8?B?NzBkPg==?= List-Help: List-Id: "9fans" <9fans.9fans.net> List-Post: List-Software: Topicbox v0 List-Subscribe: Precedence: list Reply-To: 9fans <9fans@9fans.net> List-Unsubscribe: , Topicbox-Delivery-ID: 2:9fans:437d30aa-c441-11e9-8a57-d036212d11b0:522be890-2105-11eb-b15e-8d699134e1fa:M839d78d594076ff44368770d:1:tYFs8WX7PlOQSg1vhdvMnI-bJqK3-nuzLF_kRpiqMig This is awesome, thank you Cheers, Sean On Mon, Aug 30, 2021 at 10:53 PM wrote: > > The last cheat sheet I posted was in need of revision and reordering. Thi= s one is better than the last--I hope. > > > CHEAT SHEET OF SAM COMMANDS > > x cmd - set dot and run command on each matching line > > . -- apply command to dot > > , -- apply command to whole document > > > < replace dot with std input of command > > ! run the unix command > > send dot to std input of command > > > 0 > >spell -- check spelling > >wc -l -- count just the lines > >wc -- do a line, word and character count > > > |tr a-z A-Z -- change case > > ,x/".+"/ y/"/ | tr [:lower:] [:upper:] > > OR > > ,x/".+"/ y/"/ | tr a-z A-Z > > -- to capitalise all letters inside quotes > > > s/.*/*&*/ -- enclose phrase in asterisks > > > |fold -s -- break up/format long lines > > |fmt -- idem > > |sort -- sort the file > > |uniq -- delete juxtaposed duplicate lines > > |awk '!seen[$0]++' -- delete non-juxtaposed duplicate lines > > ,x/\n+/a/\n/ -- finds every occurrence of 1 or more (+) newlines (\n) and= appends a new line. > > > /vi/ or +/vi/ -- search forward > > 0/regex/ -- search from beg. of file forwards > > 0/regex/+-p -- search for a string and select the whole line that contain= s it > > /vi/+- m 0 selects and moves the next line containing "vi" to the top of = the file > > /vi/+- t 0 selects and copies the next line with "vi" to the top of the f= ile > > > $/regex/ -- search from end of the file backwards > > > Search for a string, and then go from search results in sam window to doc= ument: > > ,x g/hello/{ > > p > > > } > > > 0,$ t "peter.c" 0 -- copy contents of one to another > > > , and ; selects whole document > > , equivalent to 0,$ > > 0;5 and 0,5 - selects 1st five lines > > > -/^/+#10 -- go to 10th column of current line > > > B < echo *.org -- One can load multiple files by using < > > B < grep -l vi * will load only those files that contain the string "vi" > > D is the complement of B. It eradicates the file from sam's memory but do= es not delete the file from disk! Without a name argument removes current f= ile > > e replaces current file with one specified > > f changes the filename > > f > n gives a list of read and loaded files > > > {} Braces group commands > > [=CB=86n] any char but n > > [nm] n or m > > > w writes the whole file, or parts of a file to disk > > < cat /home/red/bin/songs -- insert contents of a file > > r /home/red/bin/songs -- idem > > r replaces dot in the current file with the contents of the file specified > > > < /home/red/bin/songs -- insert contents of a script > > > /home/red/bin/pass google -- output contents of script to sam window > > > < echo "Hello world" -- insert ascii code at the current position > > > x/^/a/ / -- indent the selected text by 1 tab. x means apply to all lines= in the selection. > > > sam terminal information > > ----------------------- > > . indicates the current file > > + the file has a window open > > - the file has been read by sam > > * the file is open in more than one instance > > ' the loaded file differs from the file on disk > > > /.+\n/ -- finds lines with text > > /.*\n/ -- matches single whole lines > > > 0/Ben/,/Son/ -- find a range of text > > .,/regexp/ -- selects text FROM dot to the regex > > ./regexp// -- selects the second occurrence of a regex > > ./regexp// -- selects the third occurrence of a regex > > /vi/+/vi/ -- search for the second occurrence of "vi" following dot > > > p -- prints contents of dot in sam terminal > > =3D -- prints current value of dot in sam terminal > > > ,t "junk" 0 -- copy current file to start of file "junk" > > > Perform conditional ACTIONS on lines: > > g/regexp/ command -- g =3D if. If dot contains regexp, run command > > g/test/d > > ,x g/vi/p -- if a line has "vi" print the line in sam window > > v/regexp/ command -- If dot does not contain, run a command > > ,x/.*\n/ g/ed/ v/red/ p -- find lines with ed but not red > > ,x/".+"/ y/"/ -- search for text in quotes but do not show lines with "y" > > ,x/".+"/ x/"/ -- search for text between quotes and only show the quotes > > ,x /.*\n/ g/vi/ p - break file into lines, if lines contain "vi, print > > > ,x/ +$/d -- delete empty whitespace at end of every line > > ,x/'+$/i/ --color-auto/ -- insert the phrase "--color-auto" into every li= ne that ends in 1 or more ' > > > .x/Peter/d -- search dot for 'Peter' and delete 'Peter' > > ,x/\\v|\\c|\\s1|\\q1/d -- multiple deletions > > ,x/\*/d -- delete all asterisks > > ,x/^ /d -- delete the indents > > ,x/^ +/d -- delete all blank spaces at beginning of lines > > ,x/^$\n/d -- delete all blank lines > > ,x/\n\n\n+/c/\n -- change multiple blank lines into 1 blank line > > > ,x/[0-9]/d -- delete lines with numbers > > > ,x/^http.[^,]*?/d -- search for "http...," and delete > > > C-i -- create a tab stop of 8 spaces > > ,x/^/a/ / -- indents text with a tab stop. > > x/^ /d -- remove 1 tab of indent from selection > > > ,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/" -- change all smart quotes into straight ones > > ,x/".+"/ x/"/ c/'/ -- change double quotes (that surround one or more cha= racters) to single quotes > > ,x/good/ c/bad/ -- change "good" to "bad" on every line > > ,x/teh/c/the/ > > ,x/Emacs/x/E/c/e/ - change all the capital "E"s in "Emacs" to lower case = "e"s > > > X -- is an iterator that works on files not lines > > X D -- remove out all up to date files > > X/regexp/ command -- Run command on files whose menu line matches > > X/questions/D -- close file called "questions" > > X/\.sam$/,x/the/+-p -- search multiple files for text and print the resul= ts > > X/.*/,x//d -- strip from all files > > X ,x/(.+\n)+/ g/account/+-p -- look through every file, and every line, a= nd if any line contains "account" print it out in sam window > > > s/.*/& Hello/ -- add " Hello" to the end of line > > s/good/bad/ > > > The y command *excludes from consideration* in the seach that follows. > > > ,y/ben/ x/(.+\n)+/g/Directory details/p > > > Y/regexp/ command -- Exclude the file named by "regex" from consideration. > > > .x g/fred/ v/........./ c/jim/ -- Look through dot. If dot contains "fred= " change it to "jim" provided it is not "fred....." > > > ,x[a-zA-Z]+/{ > > g/fred/ v/...../ c/jim/ > > g/jim/ v/..../ c/fred/ > > } > > > In the above command braces {} allow for multiple commands. The command s= ays: search every line that contains 1 or more letters, if the line contain= s "fred" change it to "jim" and if "jim" change it to fred, provided "fred"= is not "fred." and "jim" not "jim." > > > g - "if" > > v" - "if not, unless the regex is" > > > ,| ssam -f your_script -- apply a sam script > > > 9fans / 9fans / see discussions + participants + delivery options Permali= nk ------------------------------------------ 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T5a59d8c3b404b14d-M839d7= 8d594076ff44368770d Delivery options: https://9fans.topicbox.com/groups/9fans/subscription