Skip to content

Programming Articles

  • HOME
  • Python
  • JavaScript
  • C/C++
  • Java
  • Terms & Conditions and Privacy Policy
  • About US
Main Menu

Bash

Bash / Docker / Linux

How to get bash or ssh into a running container in background mode?

Sample query: I want to ssh or bash into a running docker container. Please, see example: Now I want to get something like this (go into the running container): $ …

How to get bash or ssh into a running container in background mode? Learn More
Bash / Linux

How to merge multiple PDF files into one PDF in Linux?

Considering that pdfunite is part of poppler it has a higher chance to be installed, usage is also simpler than pdftk: Just make sure you remember to provide out.pdf, or else it will overwrite the last …

How to merge multiple PDF files into one PDF in Linux? Learn More
Bash / Linux

How to prompt for Yes/No/Cancel input in a Linux shell script?

The simplest and most widely available method to get user input at a shell prompt is the read command. The best way to illustrate its use is a simple demonstration: Another method …

How to prompt for Yes/No/Cancel input in a Linux shell script? Learn More
Bash / Linux

How to loop through the content of a file in Bash?

One way to do it is: As pointed out in the comments, this has the side effects of trimming leading whitespace, interpreting backslash sequences, and skipping the last line if …

How to loop through the content of a file in Bash? Learn More
Bash / Linux

How to change the output color of echo in Linux?

You can use these ANSI escape codes: And then use them like this in your script: which prints love in red. From @james-lim’s comment, if you are using the echo command, be sure to use the …

How to change the output color of echo in Linux? Learn More
Bash

How to loop through an array of strings in Bash?

Is it possible to loop through an array of strings in Bash? The answer is yes. You can use it like this: Also works for multi-line array declaration That is …

How to loop through an array of strings in Bash? Learn More
Bash

How to check if a variable is set in Bash?

For example, how to check if the user gave the first parameter to a function? The right way where ${var+x} is a parameter expansion which evaluates to nothing if var is unset, and substitutes the string x otherwise. …

How to check if a variable is set in Bash? Learn More
Bash

How to pass parameters to a Bash function?

Query explained: I am trying to search how to pass parameters in a Bash function, but what comes up is always how to pass parameters from the command line. I would …

How to pass parameters to a Bash function? Learn More
Bash / Shell

How to declare and use Boolean variables in a shell script?

You can use the following code for declaring and using boolean variables in a shell script: Revised Answer Original Answer How to declare and use boolean variables in a shell …

How to declare and use Boolean variables in a shell script? Learn More
Bash

How to concatenate strings in Bash?

Sample query: I need to concatenate two strings in bash, so that: echo mystring should produce helloworld How to concatenate strings in Bash? In general, to concatenate two variables you can …

How to concatenate strings in Bash? Learn More
Bash

How can I get the source directory of a Bash script from within the script itself? [Answered]

Query: How do I get the path of the directory in which a Bash script is located, inside that script? I want to use a Bash script as a launcher for another application. I …

How can I get the source directory of a Bash script from within the script itself? [Answered] Learn More
Bash

How to set a variable to the output of a command in Bash? [Answered]

Query explained: I have a pretty simple script that is something like the following: When I run this script from the command line and pass it the arguments, I am …

How to set a variable to the output of a command in Bash? [Answered] Learn More
Bash

What is the difference between single and double quotes in Bash? [Answered]

Query: In Bash, what are the differences between single quotes (”) and double quotes (“”)? Difference between single and double quotes in Bash- Answer #1: Single quotes won’t interpolate anything, …

What is the difference between single and double quotes in Bash? [Answered] Learn More

Featured Posts

From UNIX to Linux – History of Linux

21st November 202010th September 2022

Best themes for Ubuntu: Make Ubuntu Beautiful

20th October 202010th September 2022

Strings in Python

12th September 202010th September 2022

Is Python hard to learn? Top best learning resources

18th April 202010th September 2022

Recent posts

  • How to pad a string with zeroes to the left?
  • What is the difference between process and thread?
  • How to generate a random alpha-numeric string in Java?
  • How to auto-resize an image to fit a ‘div’ container?
  • How to get a Docker container’s IP address from the host?
  • How to display a JavaScript object?
Copyright © 2023 Programming Articles.
Powered by WordPress and HitMag.