Language Selection

English French German Italian Portuguese Spanish

New bash programming articles

Filed under
Development
  • How to use bash aliases

    Most of the users like to use shortcuts for running commands. There are many commands in Ubuntu that we need to execute regularly. It will be very helpful for us if we can run those common commands by typing shortcut commands. Using bash aliases, Ubuntu users can easily create shortcut commands of the large commands those are used frequently. Bash aliases not only make the task easier but also save the time of the users. The user can declare alias temporary or permanently. The temporary aliases can be used as long as the session of the user exists. If the user wants to use shortcut commands every time the session starts, then he or she has to create permanent alias by using ~/.bashrc and ~/.bash_profile files. This tutorial shows how you can create and use bash aliases in Ubuntu by using some examples.

  • Bash Arithmetic Operation

    Using bash aliases, Ubuntu users can easily create shortcut commands of the large commands those are used frequently. Bash aliases not only make the task easier but also save the time of the users. The user can declare alias temporary or permanently. How to use bash aliases is explained in this article.

  • How to use arrays in Bash

    When you want to use multiple data using a single variable in any programming language, you have to use array variables. The list of data can be assigned and used using an array variable. Bash is a weakly typed language that does not require defining any data type for declaring the variable. Array declaration in bash is a little bit different from other standard programming languages. Two types of the array can be declared in bash. Numeric array and associative array. If the index of an array is numeric, then it is called a numeric array, and if the index of an array is a string, it is called an associative array. How you can declare a numeric array, associative array, and iterate elements of the array using for loop are described with examples in this tutorial.

  • Bash Head and Tail Command

    Many types of commands are available in bash to show the content of a file. Most commonly used commands are ‘cat’, ‘more’, ‘less’, ‘head’ and ‘tail‘ commands. To read the entire file, ‘cat’, ‘more’, and ‘less‘ commands are used. But when the specific part of the file is required to read then ‘head‘ and ‘tail‘ commands are used to do that task.

    ‘head‘ command is used to read the file from the beginning and the ‘tail‘ command is used to read the file from the ending. How you can use ‘head‘ and ‘tail‘ commands with different options to read the particular portion of a file is shown in this tutorial.

    You can use any existing file or create any new file to test the functions of ‘head‘ and ‘tail‘ commands. Create two text files named products.txt and employee.txt with the following content to show the use of ‘head‘ and ‘tail‘ commands.

  • Bash Range

    You can iterate the sequence of numbers in bash in two ways. One is by using the seq command, and another is by specifying the range in for loop. In the seq command, the sequence starts from one, the number increments by one in each step, and print each number in each line up to the upper limit by default. If the number starts from the upper limit, then it decrements by one in each step. Normally, all numbers are interpreted as a floating-point, but if the sequence starts from an integer, the decimal integers will print. If the seq command can execute successfully, then it returns 0; otherwise, it returns any non-zero number. You can also iterate the sequence of numbers using for loop with range. Both seq command and for loop with range are shown in this tutorial by using examples.

  • Bash Script User Input

    In the seq command, the sequence starts from one, the number increments by one in each step, and print each number in each line up to the upper limit by default. If the seq command can execute successfully, then it returns 0; otherwise, it returns any non-zero number. Two ways to generate the sequence of numbers are shown with examples in this article.

  • BASH while loop examples

    Three types of loops are used in bash programming. While loop is one of them. Like other loops, a while loop is used to do repetitive tasks. This article shows how you can use a while loop in a bash script by using different examples.

Bash Wildcard

  • Bash Wildcard

    When we need to search for anything using shell commands then we need to define a pattern for searching. Wildcard characters are used to define the pattern for searching or matching text on string data in the bash shell. Another common use of wildcard characters is to create regular expressions. How you can use different types of wildcard characters for searching files is shown in this tutorial.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

More in Tux Machines

Best Free and Open Source Alternatives to Apple Final Cut Pro

In 2020, Apple began the Apple silicon transition, using self-designed, 64-bit ARM-based Apple M1 processors on new Mac computers. Maybe it’s the perfect time to move away from the proprietary world of Apple, and embrace the open source Linux scene. Final Cut Pro is a commercial proprietary video editing application which lets users log and transfer video, edit, process the video, and output to a wide variety of formats. What are the best free and open source alternatives? Read more

Open source photo processing with Darktable

It's hard to say how good photographs happen. You have to be in the right place at just the right moment. You have to have a camera at the ready and an eye for composition. And that's just the part that happens in the camera. There's a whole other stage to great photography that many people don't think about. It used to happen with lights and chemicals in a darkroom, but with today's digital tools, post-production happens in darkroom software. One of the best photo processors is Darktable, and I wrote an intro to Darktable article back in 2016. It's been five years since that article, so I thought I'd revisit the application to write about one of its advanced features: masks. Darktable hasn't changed much since I originally wrote about it, which to my mind, is one of the hallmarks of a truly great application. A consistent interface and continued great performance is all one can ask of software, and Darktable remains familiar and powerful. If you're new to Darktable, read my introductory article to learn the basics. Read more

What's the Difference Between Git Switch and Checkout?

When you start learning and using Git, you'll come across the common situation where you have to change branches. And here, things could become a bit confusing for you. If you look for how to switch branches in git, you'll come across some examples where git switch is used and some examples where git checkout is used. So, what's the difference between git switch and git checkout? If both can be used for switching branches, why are there two commands for the same purpose? Let me explain. Read more

Android Leftovers