toad.social is one of the many independent Mastodon servers you can use to participate in the fediverse.
Mastodon server operated by David Troy, a tech pioneer and investigative journalist addressing threats to democracy. Thoughtful participation and discussion welcome.

Administered by:

Server stats:

315
active users

#shellscripting

0 posts0 participants0 posts today

New #blog post: Gathering Hashtags from the Fediverse

https://rldane.space/gathering-hashtags-from-the-fediverse.html

282 words (2233 counting the hashtags, but that's just silly)

cc: my wonderful #chorus: @joel @dm @sotolf @thedoctor @pixx @twizzay @orbitalmartian @adamsdesk @krafter @roguefoam @clayton @giantspacesquid

(I will happily add/remove you from the chorus upon request! :)

#100DaysToOffload #27

rldane.spaceGathering Hashtags from the Fediverse

I'm exploring ways to improve audio preprocessing for speech recognition for my [midi2hamlib](github.com/DO9RE/midi2hamlib) project. Do any of my followers have expertise with **SoX** or **speech recognition**? Specifically, I’m seeking advice on: 1️⃣ Best practices for audio preparation for speech recognition. 2️⃣ SoX command-line parameters that can optimize audio during recording or playback.
github.com/DO9RE/midi2hamlib/b #SoX #SpeechRecognition #OpenSource #AudioProcessing #ShellScripting #Sphinx #PocketSphinx #Audio Retoot appreciated.

GitHubGitHub - DO9RE/midi2hamlibContribute to DO9RE/midi2hamlib development by creating an account on GitHub.

Apropos an ongoing project, looking at sed, and realising:

  • It can execute external commands (e)
  • It can read in entire files at a given address within the input stream (r).
  • It can read in specified external files on a line-by-line basis at a specified address within the input stream (R).

I've only been using sed for, oh, 40 years.

gnu.org/software/sed/manual/se

www.gnu.orgsed, a stream editorsed, a stream editor

Cute little script is cool! I wrote a little bash script to wrap around a thesaurus .txt file I found in a unix stack exchange answer (link in script).

It started out as a one-liner, but I adapted it after the results were not completely terrible, though I'm always looking for better ones.

Why are all thesauruses (thesauri? thesauruseseseses?) online and why aren't there any decent local offerings for linux?

Either way, enjoy this little standalone bash script - I'm p proud of the ranking algorithm implementation in the big piped one-liner bit at the end.

gitlab.com/sbrl/bin/-/raw/mast

Today I learned from the flock(1) man page (on Debian) that you can put this line at the top of a shell script to prevent more than one copy of it from ever running at a time:

[ "${FLOCKER}" != "$0" ] && exec env FLOCKER="$0" flock -en "$0" "$0" "$@" || :

This is an extremely clever hack and I don't know how I've never stumbled upon it in 38 years of writing shell scripts.
#unix #linux #scripting #shellScripting

I think I won't bother anymore with writing (bash) shell scripts that are longer than a few lines. I find the syntax too unintuitive and there are better programming languages like PHP that produce more readable code.

In the last two hours, I translated a bash shell script with ~250 lines to a PHP CLI script. The latter is nearly 400 lines long but definetly more readable and it also has more user-friendly output.

1/2

Interesting #ShellScripting quandary:

(solution below)

I'm uncertain how shells delimit filename variables internally.

I have a shell (bash) function that loops through a set of PDF files, opening them in zathura in a "suckless" tabbed window (so that the PDFs always open within the same window, so I can just hit q to zip through them one-at-a-time.

Here is my variable declaration:

local files=${*-*.[pP][dD][fF]}

But for simplicity, you could just imagine it to be:

files=*

Then I'm doing a

for f in $files; do

I'm wanting to print a status line for each item viewed, so I have an idea how many more there are to go, so I'm using this:

echo "[[$f]] ($count/$tot)"

And of course, there's a ((count++)) at the beginning of the loop.

But how to get the total ($tot)??

echo $files |wc -l will always result in 1, as does echo "$files" |wc -l

What I ended up doing was just creating a

for f in $files; do ((tot++)); done

One-liner loop before the actual loop, just to get a total.

Is there a better way?

Am I missing something really obvious?

Solution, courtesy of @khm

Use an array!

local files=(${*-*.[pP][dD][fF]})

echo "[[$f]] ($count/${#files[@]})"

Should've made this a long time ago:

function ciglob {
    #case-insensitive glob generator
    echo "$*" |while read -N1 c; do
        case "$c" in
            [a-zA-Z])   echo -n "[${c^^}${c,,}]";;
            *)          echo -n "$c"
        esac
    done
}
~ $ ciglob "Hello, world!"
[Hh][Ee][Ll][Ll][Oo], [Ww][Oo][Rr][Ll][Dd]!
~ $ ls -ld $(ciglob documents)
drwxr-xr-x 52 ~~~ ~~~ 20,480 Apr 10 11:45 Documents

(Not the most useful example, but I did have a use case in mind when I wrote it ;)

P.S. (This is a valid way to close a parenthesis. Fight me ;)

#bash#ksh#sh

#RaspberryPi owners, how do you back up your #RPi?
I don’t have an extra hard drive, so I need to back up to #GoogleDrive. I’ve installed #Rclone and tried creating a #BASH script, but I’m struggling with it.
If you’ve set up something similar or have recommendations for an efficient backup workflow, I’d love to hear them! Bonus points if you know any good courses or resources to improve my scripting skills.
#Linux #Tech #SelfHosted #SelfHosting #RaspberryPiBackup #RaspberryPi500 #RaspberryPiProjects #RPiBackup #RaspberryPiOS #RPiProjects #LinuxBackup #LinuxTips #LinuxCommunity #TechSupport #OpenSource #DataBackup #CloudBackup #GoogleDriveBackup #CloudStorage #FileBackup #Rclone #BASHScript #ShellScripting #ProgrammingHelp #CodeNewbie #LearnToCode #TechSolutions #Automation #techhacks @linux @selfhost @selfhosting @selfhosted

If anyone following me is learning the terminal (or was even in the class I taught this semester - blog post about that coming soon!), then this post might be of interest to you:

Free ebooks seem to be available for a limited time.

mastodon.social/@itsfoss/11374

MastodonIt's FOSS (@itsfoss@mastodon.social)Free e-books to conveniently learn about the Linux terminal and bash shell scripting! 📖 https://news.itsfoss.com/tuxmas-day-5/