How to Remove First/Last Characters from a Variable in a Shell Script

When working on a Bash or Fish script, there may come a time when you need to remove the first or last few characters from a string variable. While this task might seem straightforward, it can sometimes take longer than expected to figure out the correct solution. In this blog post, we’ll explore how to remove the first or last characters from a variable in a shell script. Removing the First Characters To remove the first n characters from a string variable, you can use the cut command in combination with command substitution....

The Command Line for Complete Beginners

Introduction to using the command line for complete beginners Using a computer with a mouse or touchpad is convenient, but there was a time when computers were only accessible through commands typed in a terminal. Even with today’s advanced technology, the terminal is still a powerful tool that unlocks capabilities beyond what a Graphical User Interface (GUI) offers. The terminal, or Command Line Interface (CLI), is not just for programmers. It is essential for any professional computer user....

Unix Shells Tutorial: An Introduction to Using Unix Shells

A shell is a command interpreter that provides users with a text-based interface to interact with the operating system. It allows you to execute operations using commands, provides advanced features like scripting, and offers optimized ways to perform tasks compared to a Graphical User Interface (GUI). Unix shells, commonly found on Linux and macOS computers, come in different variations. The most prevalent ones include Bash, Csh, Zsh, and Fish. These shells have evolved from the original Bourne Shell, commonly known as sh, developed by Steve Bourne....