news
Recent Valnet Articles on GNU/Linux Work Through the Shell/Bash/Terminal
-
HowTo Geek ☛ An introduction to the most useful special and environment variables in Bash
Are you currently learning Bash? Have you seen things like $0 and $EUID and wondered what they mean? Or what the difference is between $UID and $EUID? I'll cover these and more: what they do and why they're important.
-
HowTo Geek ☛ A gentle introduction to Bash functions
If you're just beginning Bash scripting, you may often find yourself repeating the same commands again and again in your scripts, but a better way exists. I will explain what "DRY" means and how you should use functions to do it.
When I wrote my very first program on Windows, it was a batch script. I essentially winged it, and with minimal understanding, I wrote a very literal set of instructions, peppered with GOTO statements, and repeated myself enough to make the script unreadable.
In programming, DRY means "don't repeat yourself." Functions are the mechanism to achieve that, and I'll show you how.
-
HowTo Geek ☛ Why printf is superior to echo in Linux scripts
One of the first commands new Linux users learn is echo. Need to print some text or debug a script? Add an echo statement. However, from my usage, I've found printf to be far more powerful. Once you understand its basics, it becomes a safer default for printing output in scripts.
Why echo isn’t as simple as it looks
One of the biggest issues with echo is that its behavior isn’t fully standardized. Different shells handle it differently, especially when it comes to options and escape sequences. For example, whether echo -n actually suppresses the trailing newline or just prints it verbatim depends on the shell. The same goes for escape characters like \n or \t. They may work in one environment and be printed literally in another.
-
HowTo Geek ☛ 9 easy Linux terminal commands that make you faster right away
If you don't have a lot of experience working with the terminal, it might seem like an obtuse or intimidating black box. What you might not know is that the terminal can be fun to use. So much so, that you're inclined to use the command-line over a GUI whenever possible. There is definitely a learning curve and the more you work with the terminal, the more fluent you become. However, there are some commands that everyone should know. Scroll through the command history
Except for a handful of shells, pretty much every modern Linux shell supports history scrolling. Basically, you don't have to re-type commands over and over. Instead, you can just use the up and down arrow keys to scroll through previously executed commands. Ctrl+P and Ctrl+N work too, for pulling up the previous and next commands.
Once you find your target command, you can just press the Enter key to instantly execute it. Or, you can modify and edit it before executing with the Enter key.
-
HowTo Geek ☛ A beginner's guide on expanding Bash arrays and word splitting
Have you ever been confused by the different ways to use Bash arrays? Or perhaps you're just learning Bash, and they're next on your list? Bash arrays can act strangely depending on how you use them. I will explain the confusing circumstances you may encounter when doing so.
If you've written Bash scripts in the past, you've probably encountered the for loop. Their syntax is a little awkward, and the different approaches confused me until I understood the four fundamental rules.