this post was submitted on 07 Feb 2024
51 points (88.1% liked)

Linux

48328 readers
555 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS
 

Another fun week of tinkering! Here’s what I learned:

How to implement a for loop in bash scripts using seq.

I’ve been working on a script to create folders for my tv show library to play nice with my Jellyfin server. What I wanted was for the script to:

  • prompt me for the show’s name
  • query The Movie Database: Shows api for the show
  • present me a numbered list of the show results formatted as index showname year tmdb-id
  • prompt me to choose the correct result from the list
  • create a directory formatted as Show.Name.(YYYY).[tmdbid-xxxxx]

Since the number of results will vary from query to query, I couldn’t use a preset range like {0..5} for my for loop. I tried without success to have the loop iterate through the JSON response, but I was unable to figure out how to do that.

So, while likely inelegant, What I did was:

  • take the JSON response and pipe it to jq, get the number of results
  • Since jq indexes start with 0, take the number of results and subtract 1, setting the results of that calculation as my $count variable
  • loop through the JSON using for i in $(seq 0 $count) ; do to create the indexed list of results to choose from

How to use jq to work with and extract data from JSON objects

I’m just scratching the surface of jq, but I’m finding it very useful! I’ve worked with JSON before making automations on iOS with the Shortcuts app, so getting up and running with jq was pretty easy once I understood the syntax.

Note: I know tools like Filebot exist to do the kind of thing I’m doing with this script. I’m writing my own scripts from scratch in order to learn

Git and Github are different things

On my post last week a number of people suggested using Git. I already was aware of Github, and because I didn’t know what I didn’t know, I thought Git and Github were parts of a whole. I also generally knew that Git/Github are used for version control, but that was the extent of my knowledge. I still know very little, but I do now understand that Git and Github are independent things that can work together.

I also went ahead and set myself up a gitea instance on my server for when I’m ready to create repositories for myself for my scripts and dotfiles

top 13 comments
sorted by: hot top controversial new old
[–] MyNameIsRichard@lemmy.ml 14 points 9 months ago (2 children)

Github is to git what Pornhub is to porn

[–] harsh3466@lemmy.world 5 points 9 months ago

Nice anaolgy!

[–] eager_eagle@lemmy.world 2 points 9 months ago

really confused with the grubhub business model right now

bootloaders?

[–] perishthethought@lemm.ee 9 points 9 months ago (2 children)

I'm making up Lemmy Gold to give you as a reward for these posts. Thank you!

Lemmy Gold

[–] backhdlp@iusearchlinux.fyi 3 points 9 months ago (1 children)

I thought this was gonna be a "this comment can only be viewed by lemmy gold subscribers" thing

[–] perishthethought@lemm.ee 1 points 9 months ago

That wouldn't be very "Lemmy", imo.

[–] harsh3466@lemmy.world 1 points 9 months ago

Thank you! I’m glad you enjoy them! They help me keep my own thoughts and progress organized. I had been jotting this stuff down in notes for myself, then I thought, “hey, I might as well share this on Lemmy while I’m at it.”

[–] pcouy@lemmy.pierre-couy.fr 8 points 9 months ago (1 children)

Github is not really independent from Git, it's a git provider. (you could see it as Github being to Git what Gmail is to e-mails)

[–] harsh3466@lemmy.world 2 points 9 months ago

That makes sense. I couldn’t come up with quite the right wording to distinguish between them when I was writing up the post.

[–] PlexSheep@feddit.de 4 points 9 months ago* (last edited 9 months ago) (1 children)

Cool post, didn't know about jq and seq. Keep the learning up! Your little series is really nice here.

I also went ahead and set myself up a gitea instance on my server for when I’m ready to create repositories for myself for my scripts and dotfiles

A little question, do you have really really specific skills, or how does it come that you don't know git but are able to selfhost gitea? Just really proficient with orchestration tools like docker?

Since you host gitea you might want to know. Forgejo and Gitea are almost the same software, Forgejo is a "soft fork" of Gitea maintained by Codeberg, a very pro open source non commercial Organisation pushing for federalization of "code forges". Think Lemmy/fediverse but for Git Servers.

[–] harsh3466@lemmy.world 2 points 9 months ago

Thank you (switched to an lemmy.ml account because I haven't been able to comment or post on lemmy.world for over a week)

Not really specific skills, I'm just a hands on learner/tinkerer. I've been messing with self hosting for around three years now, so spinning up new docker services is fairly easy (fairly. I still have a lot to learn about docker). In doing so, I've used and referred to github a lot, and even used git to clone repositories for self hosting a service, but beyond that, I hadn't looked into it as it didn't seem relevant to me at the time.

And thank you for the Forgejo information! I will look into that and compare to see which one I'd like to use. Coincidentally I just saw today or yesterday that Forgejo has gone for a hard fork.

[–] GravitySpoiled@lemmy.ml 3 points 9 months ago (1 children)

Did you try sonarr to manage your series library?

[–] harsh3466@lemmy.world 5 points 9 months ago

I haven’t. I’m aware of the *arrr stuff, but as I mentioned in the post, I’m writing these scripts to learn. I have no illusions that what I’m doing is better than *arrr or filebot or whatever else might be out there, I just like working on projects as a way to learn.