Questions tagged [bash]

This tag is for questions about scripts written for the Bash command shell. For shell scripts with syntax or other errors, please check them at https://shellcheck.net before posting here. Questions about interactive use of Bash are more likely to be on-topic on Super User than on Stack Overflow.

146,514 questions
0votes
1answer
6views

Equal/minus sign without a colon in a parameter expasion in bash

I've a snippet like this in a Bash script recently: $ echo ${A=3} Now, I know that ${A:=3} would set the variable A if A is "falsy", or ${A:-3} would return 3 if A is "falsy." I ...
0votes
0answers
10views

Inconsistent behaviour with grep

I've been given with the following task: Given a pattern and a text file, display the lines and number of that contain the pattern in the beginning, end, or anywhere in between. It's a fairly simple ...
-1votes
0answers
11views

How to read and delete pending messages from an ActiveMQ queue in bash scripting?

I have a requirement to read and delete pending messages from an ActiveMQ queue in bash scripting or a command to run on server (unix). I checked various platforms to get some knowledge however didn't ...
0votes
4answers
44views

Can you convert a date to yyyy/mm/dd using sed?

I have a utility that outputs the software expiration date into a text file called expiration. The file has one line and it is below: node_software_expiration_date Sat Jul 6 23:59:59 2025 I'd like to ...
-2votes
2answers
34views

Loop over values in multiple colums with condition and print first column value if true in AWK

My data is as follows (this is just a sample, real data has ~20,000 lines) : Original raw data (tsv): Names USA EU FR Jim 3 12 5 John 8 4 7 Jane 12 35 3 Sue 6 3 9 Image ...
0votes
0answers
36views

How to remove single quotes from a string using sed

If I need to remove the following line from certain files ob_start('ffggg_ggg'); I have tried grep -rl "ob_start('ffggg_ggg');" /pathtosearch | xargs sed -i 's/[ob_start('ffggg_ggg');]//g' ...
0votes
0answers
13views

Expect statement returns success for failures

I have an expect script that will execute a particular condition based on the value read using i2c_read. The issue I'm having is that script always prints "Test Pattern Successful" even in ...
1vote
0answers
28views

Longer command in bash alias

I have a command that I run for quick scans. sudo nmap -sP `ip route | grep eth0 | awk '/\// { print $1 }'` -oG - | awk '/Up/{print $2}' $ sudo nmap -sP `ip route | grep eth0 | awk '/\// { print $1 }'...
0votes
0answers
15views

Gitlab script does not store the value of the command to a variable

I have a simple script that needs to capture the test coverage which is like this script: - echo "running test coverage" - RES="$(npm test -- --coverage --watchAll=false)" - TOTAL=&...
  • 17
-4votes
0answers
24views

Issue with running a shell script in Oracle Linux

I need to run the following series of Oracle Linux commands in a shell script. I am a beginner for shell scripting and any help is appreciated. cd env-virtual source bin/activate sudo -s python3 /home/...
  • 153
0votes
0answers
16views

Getting Event Bridge Atlas working in a lambda function: Error: EROFS: read-only file system

eventbridge-atlas project: https://github.com/boyney123/eventbridge-atlas their website: https://eventbridge-atlas.netlify.app/ So I'm trying to have eventbridge-atlas generate the async-api docs and ...
0votes
1answer
29views

Delete rows that sum with two columns up to a certain value in bash [duplicate]

I have following table: filename w POS ID b c d h 766_V 13 73711300 rs35852582 0.03046218 0.49789916 0 0.0987395 75_S 13 73711300 rs35852582 0.03046218 0.49789916 ...
0votes
1answer
21views

create script or alias which presents a command that the user can edit or execute by pressing enter

I want to create a bash script say create_commit.sh which will "present" command like git commit -m 'edit this message' at the command prompt. User can then edit the commit message and press ...
-1votes
1answer
24views

how to use bash output as variable [duplicate]

I am creating a job that would first initiate an API checking what is the next available ip in a subnet with some parameters. Then i want to run "ping" check on the output (that is an IP), ...
0votes
0answers
28views

How to add a variable in jq

Im trying to add a variable while getting the info from a json file as shown below. stack=$(cat profiles.json | jq '.generic.category') email=$(cat profiles.json | jq '.central.[Need to add $stack ...

153050per page