This topic about scripts written for the Bash command shell.

Automatically Execute Bash Commands on Save in VS Code

“What if I could automatically run specific terminal commands for different kinds of files whenever I save?”

When to use PowerShell instead of shell scripts?

Let’s say that we need to write a code responsible for replace a piece of information in an existing file, or maybe just clean a directory…

Passing Host vs. Container Environment Variables to docker exec

Passing Host vs. Container Environment Variables to docker exec. Take a look at below example, on how to use environment variable from host machine vs. container while running docker exec.

Functions and Library Development

While developing bash scripts, sooner or later you will come across the fact that you periodically have to use the same code fragments. Typing them by hand is boring all the time.

Generating /etc/hosts from docker containers

```docker ps --format "{{.ID}}" | xargs docker container inspect | jq '.[] | "\(.NetworkSettings.Networks | keys[] as $k | "\(.[$k].IPAddress) \($k)") \(.Config.Hostname)"' | while read line;do echo ${line//'"'/}; done | grep -e '^[0-9]' | sort...

Version controlling your dot files

Want to version control config files like .bashrc? Here’s how.There are a few unique challenges when it comes to putting your dot files under source control. The naïve solution — just creating a git repository in your home directory — has pitfalls. What are they, and how can we do better?

What is Bash Alias and how to add one in Ubuntu 20.04

Linux commands are cool and fun to work with. Be it ls (to list files) or cd (to change the directory), they are already short and precise. This is one of the reasons we love Linux. However, if you have to repeatedly type a set of commands or a long command with too many parameters, its not fun anymore. The Linux creators were caring enough to provide a solution for that too. The solution for such cases is Bash Shell Alias.  A Bash Shell Alias(often called as a Bash Alias or simply an Alias ) is an alternate name, usually a short one, given to a command or a set of commands. This article shows how to get started with aliases and how to add them permanently in Ubuntu 20.04. It works for older versions too.

Linux Sleep Command (Pause a Bash Script)

sleep is a command-line utility that allows you to suspends the calling process for a specified time. In other words, the sleep command pauses the execution of the next command for a given number of seconds. The sleep command is useful when used within a bash shell script, for example, when retrying a failed operation or inside a loop. In this tutorial, we will show you how to use the Linux sleep command.

Bash Exit Command and Exit Codes

Often when writing Bash scripts, you will need to terminate the script when a certain condition is met or to take action based on the exit code of a command. In this article, we will cover the Bash exit built-in command and the exit statuses of the executed commands.

BASH Shell Redirect stderr To stdout ( redirect stderr to a File )

Explains how to redirect stderr to stdout to a file or vice versa in Bash under Linux, macOS, *BSD, and Unix-like systems.

Bash printf Command and Conversion specifications

The printf command takes a format and arguments and prints a formatted text. printf is a shell builtin in Bash.Typically, when writing bash scripts, we use echo to print to the standard output. echo is a simple command but is limited in its capabilities.

Portable Shell and VIM Customization

Deploy and Rollback in MINUTES!If you are someone that spends a lot of time with the terminal and vim like me, you probably have a pretty long and distinguished set of aliases and customization that you do to get the shell and vim to look and behave exactly the way you want.

Make Bash history more useful with these tips

A Linux terminal running Bash has a built-in history that you can use to track what you've been doing lately. To view a history of your Bash session, use the built-in command history: $ echo "foo" foo $ echo "bar" bar $ history 1 echo "foo" 2 echo "bar" 3 history The history command isn't an executable file on your filesystem, like most commands, but a function of Bash. You can verify this by using the type command:

How to Redirect stderr to stdout in Bash

To redirect stderr and stdout, use the 2>&1 or &> constructs. In Bash and other Linux shells, when a program is executed, it uses three standard I/O streams.In Bash and other Linux shells, when a program is executed, it uses three standard I/O streams. Each stream is represented by a numeric file descriptor:

An elasticsearch development workflow with curl and bash

# [An elasticsearch development workflow with curl and bash]( elasticsearch is not quite like other databases - this is unsurprising, because elasticsearch is actually an index server....

Bash Select (Make Menus) and Bash select Example

In this tutorial, we will cover the basics of the select construct in Bash. The select construct generates a menu from a list of items. It has almost the same syntax as for loop.If the user enters a number that corresponds to the number of one of the displayed items, then the value of [ITEM] is set to that item. The value of the selected item is stored in the variable REPLY. Otherwise, if the user input is empty, the prompt and the menu list are displayed again.

How to Create Bash Aliases

Bash aliases are essentially shortcuts that can save you from having to remember long commands and eliminate a great deal of typing when you are working on the command line.

17 Useful Terminal Commands for Coders

Terminal commands that will make your life easier.They all have an interactive command line interpreter, accessible through your terminal, called shell, that allows you to do a variety of tasks ranging from creating files and folders, to running scripts or even shutting down your computer.

Bash Case Statement and Case Statement Example

In this tutorial, we will cover the basics of the Bash case statement and show you how to use it in your shell scripts.The Bash case statement has a similar concept with the Javascript or C switch statement. The main difference is that unlike the C switch statement, the Bash case statement doesn’t continue to search for a pattern match once it has found one and executed statements associated with that pattern.

A Shell Script to Copy All files with Same Structure

A Shell Script to Copy All files from source directory to destination directory with the same structure. Copy files between two directory with same path.The script must maintain the same directory structure on destination directory. After that change the permission on destination directory. After successful copy of file, script must remove the file from source directory.