Category "bash"

Bash - How to rename files inside a directory based on names.txt

I'm sorry I can't provide the actual filenames for privacy reasons. names.txt contains several groups of lines separated by a single empty line. Each group pert

Multiple processes running bash on a ssh server

When I run the "ps" command, I can see all the processes I'm running, but for some reason, there are two identical processes(except for the PID ofc) running bas

How do I extract two different keywords from two different lines in a file in bash shell?

I have a file called data.txt. when I read the file, the content looks like the below. $ cat data.txt name: linuxVol id: 6 type: Linux dir excludes: .snapshot*

Why does xtrace show piped commands executing out of order?

Here's a simple reproducer: cat >sample_pipeline.sh << EOF set -x head

Write a backlink in regular terms to determine the equality of two numbers

Please tell, how it is possible to execute it For example the person entered 24 and 24 appeared on the screen "ok", on the contrary when entered 24 and 23 perso

Keeping quotes from std out for passing to bash

Okay, this is a bit convoluted but I've got a python script that digests a json file and prints a string representation of that file like so for id in pwds.keys

how to perform string operation in an input string and get the desired output

I have to write a shell script to accept the product order details as string input and display the total order amount and number of order under each category.

How do I deal with a filename that starts with the hyphen (-) character?

Somehow, at some point, I accidentally created a file in my home directory named '-s'. It is about 500 kb and I have no idea if it contains important data or no

Script to double quotes

I have a keyboard that does not have double quotes, when I need to use it, it's very difficult to remember the FN. How can I create a script so that when I pres

Read and Modify the key value in XML using Bash/Shell script

I need to read (store in variable) and then change the online_hostname key value in XML using bash/shell script. <?xml version="1.0" encoding="UTF-8" ?> &

Systemd unit file escaping issue

I am wanting to generate a secret key for a django project, that runs using podman run --new, so it generates a new container from scratch when the machine is r

echoing PROMPT_COMMAND from terminal and from bash script

while trying to write a bash script i encountered a strange issue when i try to execute it. i want to echo the $PROMPT_COMMAND variable thus, i have the followi

How to execute script as bash using "at"?

It was a pain to google solutions for my problem since it is using application "at" :) So the thing is, I am trying to run long runnng operation (I know that I

OCI runtime create failed: container_linux.go:380

I am trying to start a container from the given image below but I am getting the following error: ERROR: for code_challenge_api Cannot start service api: OCI

Bash - Remove leading zero for numbers with double digits

I have a variable in bash number which contains values 01, 02, 03, 04, 05, 06, 07, 08, 09, 010, 011, 012. I would like to remove the leading zeros before 010,

should I still declare GOPATH?

I WAS reading Learning GO and suggest that needs to be declared on PATH GOPATH="/home/user/go". this is from author: it’s a good idea to explicitly defin

How can I query in a bash script which of the haproxy load balancer hosts is currently the primary and which is the secondary?

I want to be able to determine which LB is primary and which is secondary from a bash script running on both load balancers. Background is: For the renewal of a

Repo forall reading to file

I am trying to get out some input into my files. I am doing this repo forall -c 'base=$(pwd);basename $base>names.txt' repo forall -c 'git rev-parse --abb

Prefix every line of bash script output with time since script start

Main question in the title: I want to prefix every line of script output with time since start of the script. Background. I use GNU parallel to run jobs, some o

How do I move Source Code from a local GitLab to AWS GitLab environment using automation?

As a part of my job, I have to automate Sorce code movement from development environment to Production environment. The developers push the code to GitLab that