linuxgal, to random
@linuxgal@techhub.social avatar

Morse code with #Sed

#!/bin/sed -rf
s/./\U&/
s/$/\nA.-B-...C-.-.D-..E.F..-.G--.H....I..J.---K-.-L.-..M--N-.O---P.--.Q--.-R.-.S...T-U..-V...-W.--X-..-Y-.--Z--../
:a
s/([A-Z])([^\n]
\n.\1([-.]+))/\3 \2/
ta
s/\n.
//

#XF

juandesant, to random
@juandesant@astrodon.social avatar

I tend to follow the logic of awk better than the one of sed (not being a vi enthusiast), but it is good to see when one might be better than the other:

https://www.linuxjournal.com/content/text-manipulation-linux-awk-vs-sed

chmouel, to Bash
@chmouel@fosstodon.org avatar

Something that served me well over the year, viewing a configuration files without the comment and the newlines with sed:

sed -e '/^#/d' -e '/^$/d' file.conf

so you can see a clean version of all the settings you have set in the file..

visone, (edited )
@visone@fosstodon.org avatar

@chmouel

I would add this to filter out empty lines

sed -e '/^#/d' -e '/$^/d' -e '/^[[:space:]]*$/d'

sergio_101, to ChatGPT
@sergio_101@mastodon.social avatar

for like more than 30 years, i have kinda skirted writing serious , getting good with and , and getting really good with because it usually meant a TON of digging through old documentation and piecing things together. Recently, i just started asking things like:

How do I flip through a directory of a bazillion zip files, uncompress each one, put the contents on my NAS, and then move those zip files somewhere else for safekeeping?

and learn from the answer

kelidanovus, to linux
@kelidanovus@hachyderm.io avatar

Folks on stack exchange will say “oh it’s real simple using sed“ and then post the most arcane line of undecipherable Deep Magic you’ve ever seen.

#linux #sysadmin

xdydx,
@xdydx@mastodon.social avatar

@kelidanovus
I used #sed of my own volition this week and the box is still not smoking! :)

jacobydave, to random
@jacobydave@mastodon.xyz avatar

I use sed and awk enough to know I should use them, but not enough to know, necessarily, whether it's sed or awk I need at any specific instance.

mjgardner,
@mjgardner@social.sdf.org avatar

@jacobydave when your data has records (lines) and fields (columns).

when it doesn’t.

Combine to taste.

And when you get tired of smushing everything through text pipes or cross-platform differences forcing portable code down to the least-common denominator of features, do what @cestith said and use : https://mastodon.social/@cestith/111857559756385921

Wuzzy, to random German
@Wuzzy@cyberplace.social avatar

der :

Walter Ulbricht (), 15.6.1961: »Niemand hat die Absicht, eine zu errichten.«

Bernd Baumann (), 21.1.2024: »Keiner will deutsche Staatsbürger

Wuzzy,
@Wuzzy@cyberplace.social avatar

The previous toot in :

of :

Walter Ulbricht (), 15/6/1961: “Nobody intends to build a wall [the Berlin Wall].”

Bernd Baumann (), 21/1/2024: “Nobody wants to deport German citizens.”

linuxgal, to linux
@linuxgal@techhub.social avatar

I use my #Linux Jedi light saber (#Vim) to make a #sed script to remove links to the #Mastodon posts I wanna keep. Clock is ticking on everything else. #C42

ChristosArgyrop, to php
@ChristosArgyrop@mstdn.science avatar

I think I am 50% done finding a quadrafecta : a simultaneous hit piece against & .

This one only manages to trash talk and , so it has some ways to go.

https://stefanoborini.com/why-r-is-the-new-perl/

PS 1Gotta admit that the point about the object systems in R is somewhat spot on
PS 2 gets a dishonorable mention
PS3 I will continue to find ways to continue using all 4 of the aforementioned languages, as they are all performant and deliver in complementary ways.

mjgardner,
@mjgardner@social.sdf.org avatar

@ChristosArgyrop @BobOHara By "happily derivative," Larry meant that intentionally resembles other languages and tools.

In context, he was responding in 1992 (Perl's current version was 4.035) to @bduncan whinging, “It's sorta like , but not. It's sorta like , but not.” https://groups.google.com/g/comp.unix.shell/c/J8fGo0oGUCk/m/LhF4pSEaOMwJ

mjgardner,
@mjgardner@social.sdf.org avatar

@Edwardsmoon @ChristosArgyrop @BobOHara @bduncan Yes, deliberately borrows familiar things from culture, including #C, , , and . The goal isn’t necessarily to replace them, but to remove friction when combining their capabilities.

@randalschwartz's Perl solutions to Unix questions usually demonstrated such reductions.

mjgardner,
@mjgardner@social.sdf.org avatar

@ChristosArgyrop @Edwardsmoon @BobOHara So… fashion and received wisdom traced back to the turn-of-the-century boom in shitty , supported by the belief that they're protected from building a shitty melange of , , , , and ?

mjgardner, to programming
@mjgardner@social.sdf.org avatar

@Perl Happy 36th to the language!

v1.0 then:
“Perl is kind of designed to make and semi-obsolete […] The language is intended to be practical (easy to use, efficient, complete) rather than beautiful (tiny, elegant, minimal).” https://github.com/Perl/perl5/releases/tag/perl-1.0

v5.38.2 now:
“Perl is […] now used for a wide range of tasks including , , network programming, development, and more.” https://perldoc.perl.org/perlintro#What-is-Perl%3F

mjgardner,
@mjgardner@social.sdf.org avatar

@sjfloat @Perl When you get tired of escaping metacharacters in your and pipelines, when you get tired of inventing new ways to pass structured data between small tools as text streams, is there.

Of course, you can take that last point too far. See or even , where half the “fun” is marshalling between bespoke data structures.

SweetAIBelle, to random

This might sound silly, but I installed virt-manager to make things a little easier when using qemu, then created a new virtual machine with debian 12 on it... then installed qemu on that.

The actual reason for this is to make github account separation a little easier...

If you get virt-manager set up properly, it definitely makes using qemu easier, though. I practically just had to tell it to make a new virtual machine using this iso with this much memory and this big of a hard drive, and it was right at the debian install screen. (Set it up with xfce...).

Main tricky parts were that I had to install libvirt first, make myself a member of the libvirt user group, enable the service, and install dnsmasq. Not great, but could've been worse...

Used debian on the virtual box just for a little variety. I like to keep my hand in on different distributions a bit.

kkarhan,
@kkarhan@mstdn.social avatar

U mean, peaople say / is hard, but compared to it's like & compared to using / & to write mathematical formulas in by hand on a Teletype...

But then again those that can do the latter really know their shit backwards and upside down so hats off to them...
https://www.youtube.com/watch?v=XGo4PJd1lng&t=195s

bytephantom, to infosec
kkarhan,
@kkarhan@mstdn.social avatar

@bytephantom /me *points towards #ne because #emacs is #bloatware, #vi / #vim / #neovim ain't noob-friendy and people using #sed & #awk to edit files are like #GalaxyBrainChair - type of #NextLevel...

Also it has a cool #TUI with menus so even better than #nano.
https://ne.di.unimi.it/

tivasyk, to Bash
@tivasyk@mastodon.social avatar

through all of my sysadmin experience i've been using and avoiding … for some reason. scratch that: for no good reason.

awk is to sed what python is to brainfuck.

the awk programs are a lot more easy to compose and modify, flexible and readable. and there's a brilliant book by the authors — now awailable for a free read from archive.org!

in retrospect, i can't see any tasks that i should have done with sed instead of / awk.

YesIKnowIT, to linux
@YesIKnowIT@mastodon.social avatar

Right-align text on 80 columns:
sed -E ':a /.{80}/!{s/^/ /;ba}' file

#Shell #Sed #Linux

YesIKnowIT, to linux
@YesIKnowIT@mastodon.social avatar

Centering text on 80 columns with stars:
sed -E ':x
s/^.{,80}$/&/
s/^.{,80}$/&
/
tx
' file

#Shell #Sed #Linux

governa, to linux
@governa@fosstodon.org avatar

15 #Sed Command Tips for #Linux System Administration Tasks 🐧

https://www.tecmint.com/linux-sed-command-tips-tricks/

phette23, to random

new to me: sd https://github.com/chmln/sd simple, intuitive find-and-replace command-line tool. I love sed (as one must) but it does have its quirks and does so much with operations formatted differently (why is the command char in different places? Substitute is s/.../.../ but delete is /.../d).

I'm a fan of these improved versions of unix tools (exa, fd, dust), usually written in rust or go. The classics are great but glad we're not stuck with them forever.

scy,
@scy@chaos.social avatar

@phette23 The command char isn’t in different places. sed is basically

<where><command><options>

[s]ubstitute takes search & replace as options. [d]elete-line doesn’t take any. Your s example has no <where> (runs on every line), your d example no <options> (runs on matching lines only).

And yes, you can totally do

/foo/s/bar/baz/

to replace bar with baz on every line that matches foo.

gnemmi, to linux
@gnemmi@mastodon.sdf.org avatar

Im not sure I ever shared this link in here .. but since I always find myself coming back to it, I'll go ahead and share it anyway.

This is the most helpful resource on #sed that I've ever found!

Thank you Mr. Bruce Barnett! 🤗

https://www.grymoire.com/Unix/Sed.html

#RUNBSD #BSD #Linux

chakuari, to random Italian
@chakuari@mastodon.bida.im avatar

Added #abook to #neomutt. Great tools!
#OpenBSD

kkarhan,
@kkarhan@mstdn.social avatar

@chakuari OFC.

In theory offering more than just one is "trivial" in the sense that for OS/1337 the idea is to have statical binaries (and maybe the few necessary configs) as "" so it's just a download as an archive ( because it's available in ) and just pull that and place them in the system.

OFC absolute hardcore folks will literally do just with , , & I guess, but ideally offering a convenient alternative like is better.

wh0x3r, to python Portuguese
@wh0x3r@mastodon.social avatar

programando em e pensando como é tão familiar com php

parece uma fusão de +

mjgardner,
@mjgardner@social.sdf.org avatar
  • All
  • Subscribed
  • Moderated
  • Favorites
  • provamag3
  • rosin
  • mdbf
  • everett
  • DreamBathrooms
  • Durango
  • magazineikmin
  • thenastyranch
  • Youngstown
  • osvaldo12
  • slotface
  • vwfavf
  • khanakhh
  • kavyap
  • megavids
  • ngwrru68w68
  • cubers
  • modclub
  • tester
  • InstantRegret
  • ethstaker
  • tacticalgear
  • normalnudes
  • cisconetworking
  • anitta
  • GTA5RPClips
  • Leos
  • JUstTest
  • All magazines