Look up "shellcheck", find a plugin for your editor. It should help a lot.
Linux
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
- Posts must be relevant to operating systems running the Linux kernel. GNU/Linux or otherwise.
- No misinformation
- No NSFW content
- No hate speech, bigotry, etc
Related Communities
Community icon by Alpár-Etele Méder, licensed under CC BY 3.0
Oh goodness, this looks incredibly useful. Thank you!
Congrats! It's fun and empowering to make your own tools, isn't it?
Absolutely. I love it.
Great job!
Learning Bash scripting and Vim is on my to-do list. 🎯
Thanks! I wrote the script in vim too! :D
I'm no vim expert but I do like it.
Good job! Flexible tools empower us. Keep it up and spread the love with other people!
find
is super arcane; most people don't know how to use it. Congrats!
(a note for the future with all programming, be careful of numbers with leading zeros, they might indicate base-8, causing your program to fail on 09)
Nice! Might modify this and use it for my own collection if that's cool 🤗
Of course! Feel free!! And thank you!
I have studiously avoided learning any bash scripting for the 17 years I've used Linux, so all I can say is good job! Actually just today I found a command that I needed to get a certain appimage to run without crashing, and I remembered enough that I was able to make it into a script (I struggle with whether it's !# or #!). Having just done it today, I can confirm you don't need to include '/bin/bash', just FYI. I believe that is assumed.
~~It makes it usable without typing bash~~. Same would apply for a python script. For example you can make a python script named with no extension and add #!/usr/bin/python to the top of the file. Bash shell sees this and knows to execute the script using that python path.
Then you just include the directory in your $PATH and chmod +x the script. Then you can type $python_script instead of $python python_script.py
I've had to learn heavy duty bashing for work, and happily did take the plunge. However, they also had me learn PHP and I'll drop this as a hook and line for OP: you can do shell-script duties with PHP also, and once you hit your head on sed enough times, I hope you remember me telling this. All that string manipulation is much nicer with PHP functions, and for running shell commands there is shell_exec(). :)