Jump to content

Search the Community

Showing results for tags 'bash'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • General Discussion
    • Artificial Intelligence
    • DevOps Forum News
  • DevOps & SRE
    • DevOps & SRE General Discussion
    • Databases, Data Engineering & Data Science
    • Development & Programming
    • CI/CD, GitOps, Orchestration & Scheduling
    • Docker, Containers, Microservices, Serverless & Virtualization
    • Infrastructure-as-Code
    • Kubernetes
    • Linux
    • Logging, Monitoring & Observability
    • Red Hat OpenShift
    • Security
  • Cloud Providers
    • Amazon Web Services
    • Google Cloud Platform
    • Microsoft Azure

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


LinkedIn Profile URL


About Me


Cloud Platforms


Cloud Experience


Development Experience


Current Role


Skills


Certifications


Favourite Tools


Interests

Found 10 results

  1. The post How to Fix “bash: curl: command not found” Error first appeared on Tecmint: Linux Howtos, Tutorials & Guides .If you’re a Linux user and you’ve ever encountered the error message “bash: curl: command not found” or “bash: /usr/bin/curl: No such file or directory” The post How to Fix “bash: curl: command not found” Error first appeared on Tecmint: Linux Howtos, Tutorials & Guides.View the full article
  2. Regular expressions (regex) are a powerful tool for defining patterns within text. These patterns serve as robust mechanisms for searching, matching, and manipulating text, significantly reducing the amount of code and effort required to perform complex text-processing tasks. When used within Bash scripts, regex can help automate and streamline a variety of operations. In this blog post, we'll briefly touch upon what regex is, explore some common regex metacharacters, and demonstrate how to use regex inside Bash scripts. Whether you’re a system admin, a programmer, or someone curious about improving your scripting skills, knowing how to use regex in shell scripts is a valuable skill. So, without further ado, let’s dive in! ... View the full article
  3. Bash loops are a powerful tool for automating tasks in the Unix and Linux command line environment. They allow you to repeat commands or iterate through a list of items, making them an essential skill for sysadmins, developers, and anyone looking to streamline their workflow. In this blog post, we'll explore five practical use cases of bash loops, complete with code examples. Click Here To Read More
  4. In the dynamic world of DevOps and system administration, command-line proficiency is a crucial skill. Bash, one of the most widely used command-line shells - and the default for most Unix-based systems, including popular Linux distributions - offers immense power and versatility. Mastering Bash scripting can give you a competitive edge in the automation-reliant field of DevOps. This blog post, based on the Advanced Bash Scripting course offered by KodeKloud, serves as a comprehensive guide to mastering Bash scripting. Understanding Bash ScriptingBash scripts are essentially command-line programs written in the Bash shell language. They are used to automate tasks and execute commands in a series. Bash scripts simplify complex tasks and are often used in system administration and programming. The scripts are executed in a terminal window, and they can be created using any text editor. Why Advanced Bash Scripting?With bash scripting, you can write scripts that can perform complex operations, manipulate data, and interact with the system. It is a versatile language that can be used on almost any platform, making it an excellent choice for system administrators and developers. Learning bash scripting is an investment in your future, as it can help you work more efficiently and effectively. The KodeKloud CourseKodeKloud offers a comprehensive course on Advanced Bash Scripting, designed to equip learners with the knowledge and skills to effectively utilize Bash. The course covers Bash scripting conventions and best practices, working with variables, functions, and parameter expansions, understanding streams, and managing input/output redirection, among other topics. The course is tailored for visual learners seeking an engaging and up-to-date learning experience. It balances theory and practice perfectly to ensure learners easily grasp Bash’s intricate concepts. From a theory perspective, the course explores widely discussed concepts like using curly braces for variable expansion, file descriptors, and what POSIX compliance means, along with its implications for syntax choice. From the practical perspective, it includes guides for modern Bash features, including associative arrays using key-value pairs for accessing array elements, introductory tutorials for popular command-line utilities like awk and sed, and Labs for practicing each learned concept to complement the learning experience. By mastering the concepts covered in this course, you will enhance your Bash proficiency and gain the confidence to write superior and more robust scripts. You'll understand how to create, read and debug scripts. Additionally, you’ll master how to implement script logging and error handling. Enroll in the Advance Bash Scripting Course! The Power of Bash ScriptingBash scripts can help automate a wide range of tasks and manage system configurations, making your work more efficient and reliable. By taking the KodeKloud course, you will develop practical skills in Bash scripting, including writing robust scripts that follow best practices. You will also learn how to manage input/output redirection, work with variables and functions, and use parameter expansions. These valuable skills will enable you to effectively use Bash scripting in your own work. Advanced Bash Scripting ConceptsIn addition to learning practical skills in Bash scripting, the KodeKloud course covers advanced concepts that allow users to leverage the full power of Bash. These concepts include associative arrays that use key-value pairs to access array elements as well as introductory tutorials for popular command-line utilities like awk and sed. With this knowledge, users can perform complex text-processing tasks using Bash scripts. Career Opportunities with Bash Scripting MasteryBy mastering Bash scripting, you will be well-positioned to pursue career opportunities in software development, IT management, and DevOps engineering. It will open up unparalleled career opportunities, allowing you to prosper in the system administration and DevOps fields. Whether you're automating deployments, managing system configurations, or writing complex data analysis scripts, mastery of Bash scripting will be a valuable asset. Enroll Now! ConclusionIn conclusion, Bash scripting is a powerful tool that every DevOps professional and system administrator should master. The KodeKloud Advanced Bash Scripting course provides a comprehensive guide to mastering its application, covering everything from the basics to advanced concepts. So, are you ready to enhance your DevOps or SysAdmin skills and gain command-line mastery? Enroll in the KodeKloud course today and unlock the power of Advanced Bash Scripting! Here's to your DevOps journey! New to Linux and Scripting? Start with our beginner courses: Linux Basics CourseShell Scripts for BeginnersWant to certify your Linux skills? Check out our certification exam preparation courses: Linux Foundation Certified System Administrator (LFCS)Linux Professional Institute LPIC-1 Exam 101Red Hat Certified System Administrator(RHCSA) SUBSCRIBE to gain access to this comprehensive course as well as 65+ additional courses on Linux, DevOps, AWS, Azure, GCP, Kubernetes, Docker, Ansible, Terraform, Python, and more. Join us on this transformative educational adventure and unlock the power of the bash scripts. View the full article
  5. Bash has many shell script files to set the system configurations. The “.bash_profile” file is one of them. It is a hidden file and it executes every time when the user logs in to the system. Each user has his/her “.bash_profile” file. When a new user account is created, a new “.bash_profile” file is created for that user. This file contains all configuration data of the shell for the currently logged in user, such as the command history, command aliases, environment variables, etc. Many types of settings can be set or unset by editing this file. Benefits of Using the .Bash_Profile or .Profile File The “.bash_profile” or “.profile” file is mainly used to set the environment variable for the user or define any script to perform the automated tasks at the startup of the system. The “.bashrc” file can be used for the same purpose. If you change any setup and wants to display the output at the startup only and you don’t want to see the changes every time you open the terminal, it is better to modify it to the “.bash_profile” or “.profile” file instead of the “.bashrc” file. Different Uses of .Bash_Profile or .Profile File If you don’t get the “.bash_profile” file, search the “.profile” file in the system. Run the following command to open the file to edit with the root permission: $ sudo nano .bash_profile Example 1: Set a Variable with a Default Value Add the following lines at the end of the file. A variable is exported with the string value and the printf command is used to print the value of the variable in the terminal at the startup of the system: #Set the variable with the default value export name="Welcome to Linux world" printf "$name\n\n" If the system is restarted and a terminal is opened, the following output appears. The value of the $name variable is printed in the output: Example 2: Set a New PATH Location The $PATH variable is used to add the new path location to the existing value of the $PATH variable. Open the “.bash_profile” file and add the following content at the end of the file. Here, a new path, $HOME/temp, is added in the $PATH variable. This variable is exported and printed later: #Set a path value PATH=$PATH:$HOME/temp; export PATH; printf "The value of the PATH variable:\n $PATH\n" If the system is restarted and a terminal is opened, the following output appears. The new path location that is added in the $PATH variable is shown in the output. The new path is “/home/fahmida/temp”. Example 3: Add the Short Form of the Commands The “alias” command is used to create the short form of any command. If it is required to execute any long command frequently, it is better to create the shortcut of that long command with the “alias” command and use the short form of the command when required. Two simple uses of this command are shown in this example to know the use of the command. The “date” command is used to print the current date and time value while the “mkdir” command is used to create a new directory. Open the “.bash_profile” file and add the short form of these commands at the end of the file. #Set the alias command alias dt='date' alias cdir='mkdir' Restart the system and open the terminal. The use of the “mkdir” command is shown in the following output. The “cdir” command is created as the alias command of the “mkdir” command. Here, a new directory named “tempdir” is created using the “cdir” command. Next, the “ls” command is executed to check whether the new directory is created or not. Example 4: Print the Current Date and Time in the Startup Open the “.bash_profile” file and add the following lines to print the current date and time at the startup of the terminal. Here, the short form of the “date” command is used to print the current date and time in the startup that is created in the previous example. #Display the current date and time printf "\nToday is " dt Restart the system and open the terminal. The current date and time are printed in the output to execute the “dt” command. Conclusion Many automated tasks like running a script, opening an application, and others can be done very easily using the “.bash_profile” or “.profile” file. Simple uses of this file are shown in this tutorial using different types of examples such as setting the $PATH variable, using different commands, etc. The purposes of using the “.bash_profile” file will be cleared after reading this tutorial. View the full article
  6. “Bash shell offers the export command, a built-in command that allows exporting variables in a shell to make them global, such that you can access them from another shell. With the export command, you export the environmental variables to other shells as a child process without tampering with the existing environmental variables. This guide discusses the Bash export command, giving examples of how you can use it.” Understanding the Bash Export Command The export command has only three options. -n: used to indicate the named variables won’t be exported -p: used to list all exported variables and functions -f: used when exporting functions Let’s have an example to understand when and where the export command comes in handy. Suppose you are in the current shell and create a local variable named demo1, as shown below. If we want to access the variable’s value, we could use the echo command. $ echo $demo1 However, if we opened another shell using the bash command and tried to get the value of the declared variable in the other shell, we got nothing as an output. This happens because the variable we created was local to the given shell. If we want to make it global, we must export it. Let’s return to our previous shell and export the variable using the below command. $ exit $ export demo1 If we go to a new shell and echo the variable, we see that we now get a value, meaning we have access to the variable. That’s all possible because we exported it using the export command. Viewing Exported Variables If you run the export command with no arguments, it will list all the exported variables in your system regardless of the shell. However, if you add the -p option, it will only list the exported variables in the current shell Notice that we have the variable we exported at the bottom of the list. Exporting Functions You can go beyond variables to export even functions with the export command. To make the shell recognize that you are exporting a function, use the -f flag. Let’s create a function, export it in the current shell, then try to access it in another shell and see if that works. With our function created, we can verify that it’s unavailable in the new shell, as shown below, where it returns an error. So, go back and export it using the -f flag. Lastly, open a new shell and verify that our function is now global. Bingo! You managed to export a function. Setting Values You can set the value of a variable using the export command. For this, you need the syntax below. $ export name[=value] For instance, if we wanted to change the value of the variable we created, we could use the below command. Once updated, echo the variable to check if it reflects the new value. That’s how you can manipulate other environmental variables, such as setting the default editor. You only need to grep the currently set editor and set a new one. Let’s check the current default editor using the command below. $ export | grep EDITOR In this case, we have no currently set default editor. Let’s go ahead and set one like vim or nano using the command below. $ export EDITOR=/usr/bin/nano If we check again, we see that the variable value was modified. Conclusion This article has focused on understanding the bash export command and how to use it. We’ve given various examples of how to use the export command options to export variables and functions. Knowing how to use the export command comes in handy when working with bash scripts. So, don’t stop here. Keep practicing! View the full article
  7. While a user is working bash script execution in a Linux system, different sets of bash commands need to be executed from the terminal window based on the various requirements. After running bash commands, it shows the output on the terminal if no error exists otherwise an error message shows on the command-line window. Sometimes, users want to keep this output for future use. In this situation, the output of these commands can be stored in a variable... View the full article
  8. Date command is an external bash program that allows to set or display system date and time. It also provides several formatting options. Date command is installed in all Linux distros by default. $ The post How to Work with Date and Time in Bash Using date Command first appeared on Tecmint: Linux Howtos, Tutorials & Guides. View the full article
  9. In this article, you will learn from printing a simple “Hello World” to using conditional statements such as if statements, case statements to using loops such as while, for until loops to awk, grep, sed, and debugging bash scripts. We will cover the following topics in this article: The following topics of bash scripting are covered in this article: Hello Bash Scripting Redirect to File Comments Conditional Statements Loops Script Input Script Output Sending output from one script to another Strings Processing Numbers and Arithmetic Declare Command Arrays Functions Files and Directories Sending Email via Script Curl Professional Menus Wait for a File system using inotify Introduction to grep Introduction to awk Introduction to sed Debugging Bash Scripts View the full article Watch 3 Hour BASH COURSE On YouTube
  10. Bash is just a shell that allows you to communicate with the computer and allow you to give instructions to it. A script is basically just a set of instructions given to the computer to execute different meaningful tasks... View the full article
  • Forum Statistics

    42.5k
    Total Topics
    42.3k
    Total Posts
×
×
  • Create New...