this post was submitted on 10 May 2025
12 points (100.0% liked)

Shell Scripting

1442 readers
3 users here now

From Ash, Bash and Csh to Xonsh, Ysh and Zsh; all shell languages are welcome here!

Rules:
  1. Follow Lemmy rules!
  2. Posts must relate to shell scripting. (See bottom of sidebar for more information.)
  3. Only make helpful replies to questions. This is not the place for low effort joke answers.
  4. No discussion about piracy or hacking.
  5. If you find a solution to your problem by other means, please take your time to write down the steps you used to solve your problem in the original post. You can potentially help others having the same problem!
  6. These rules will change as the community grows.

Keep posts about shell scripting! Here are some guidelines to help:


In general, if your submission text is primarily shell code, then it is welcome here!

founded 2 years ago
MODERATORS
 

I have a little programming experience but am completely new to shell scripting.

I have several hundred mp3s which I want to split using mp3splt with the command

mp3splt -A XXX.txt XXX.mp3

I have run this command by hand in the past but now have a project where doing it by hand would be impractical due to the number of files. In my imagination it should be easy to write a script that searches a folder for all the mp3s that have a txt file of the same name and runs the above command on them.

My question just is this: Is there any obvious reason this would not work? If you (meaning: a person with experience in shell scripting) don´t see any such reason, I´d work my way through this tutorial to work out the rest. If, on the other hand, you say it is impossible, I can just stop and do it by hand.

Thanks in advance!

In case you are interested in my use case: I play irish music, which is based on short melodies played by heart. I want to learn these melodies using anki with audio files. For that, I need to have audio files with just one specific tune each.

you are viewing a single comment's thread
view the rest of the comments
[–] Kissaki@programming.dev 6 points 6 days ago

You linked a tutorial to sh. Note that nobody ends up shell scripting in sh. People will use bash, which is an alternative shell and shell language, and almost universally available where sh is available. sh is very old and limited. bash is much more common.

There's many other kinds of shells as well though. And you such an automation task you could use any number of scripting languages. The part that makes it a shell, which is interactive use, is not necessary for a scripting task like this of automating an operation. Shell languages can be used as scripting languages too though. I just want to point out alternatives and context.

Personally, I use Nushell as my daily shell and for scripts and am very satisfied with it. It's not universally available as in pre-installed, but is multi-platform and easy to install through an exe or package. Because it's a newer project, there's not that many resources yet, and still occasionally makes changes to its language with new releases. But, for me, the upsides to other shells are obvious and significant. I posted my Nushell solution in a separate comment (separating concise solution from this general prose exploration).