Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [bash]

**** IMPORTANT NOTE: Do not ask a bash question until after you have copy/pasted your script into http://shellcheck.net and fixed all of the issues it tells you about. **** This tag is for questions about scripts written for the Bash command shell. Questions about the interactive use of Bash are more likely to be on-topic on Unix & Linux Stack Exchange or Super User than on Stack Overflow.

bash
0 votes
0 answers
11 views

crontab to run .sh file calling python script

I have an python selenium script that opens chrome and run a few automated task for me. Calling the python directly in crontab works with the line below. :10.0 is the value I get when i run echo $...
Aaron's user avatar
  • 57
1 vote
4 answers
46 views

Splitting and substitution by comma is not working in shell script

I have a string z="job_name=market_scenario,channel=GOOGLE FACEBOOK INSTAGRAM,time_limit=60sec" Now I want the data in the below format: job_name=market_scenario channel=GOOGLE,FACEBOOK,...
abhi pratap's user avatar
0 votes
0 answers
14 views

How to withdraw the previous command in bash [closed]

(1)I am learning how to use command in bash. I excute a command by mistake,and use "mv" wrongly to make some system file into the /tmp dictionary I search on google but make no sense. Is ...
user26534473's user avatar
-3 votes
0 answers
30 views

Proper syntax for creating .bashrc alias so that invoking (ex.) 'ai $' launches ai with $ parameters?

I have a chatgpt app I use in terminal, I'm trying to set an alias 'ai $' which launches chatgpt $, meaning "chatgpt" + whatever parameter $. Thank you. Tried alias ai='chatgpt "$"'...
Anarchy_79's user avatar
0 votes
0 answers
16 views

Apple hardware modules in directory other than that used by Linux kernel for startup modules [closed]

I recently installed Linux on a 2019 MacbookPro and do not have the ability to use the laptop trackpad or keyboard, nor to connect to a WiFi network. I am wondering, is my path to the startup modules ...
rollther's user avatar
0 votes
1 answer
41 views

for j in os.system("ls *.out") Doesn't iterate. Changing the name of files depending on extension [duplicate]

I am trying to write a script that will help me run a model several times changing the input of one value of the input files. The model over writes the output files so I need to rename the outputs ...
Rafaella Chiarella's user avatar
0 votes
0 answers
26 views

Github CLI: repo counts without details

The --limit option of gh has an upper value limit. This is set to reasonable values, and for understandable reasons; as discussed here. It can be convenient to format the output of gh as JSON, and ...
user2023370's user avatar
  • 10.9k
-2 votes
0 answers
42 views

Is measuring CPU time wrong in this (parallel) situation? [closed]

I'm running some graph algorithms that take a long time to run, so I need to set a timelimit to ensure it doesn't run for weeks. I have a 12 core CPU and 24 graphs to run the algorithm, so I set the ...
nogrodrigo's user avatar
0 votes
0 answers
15 views

Jenkins doesn't receive correct code from sh script out of podman container

I have a Jenkins pipeline where I run tests in a container and the tests are triggered by .sh script. There is an intermittent problem when script returns exit code 1, but some how Jenkins stage ...
Ellina's user avatar
  • 293
0 votes
1 answer
53 views

Сreating multilevel json with the jq utility in a bash script

I get the contents of a text file into an array and then sequentially get the elements of the array and try to add the elements to the json: #!/bin/bash JSON=$(jq -n '') readarray -t array < ./...
AndAsh AndAsh's user avatar
0 votes
0 answers
38 views

Shell script to add and commit in batch of files at a time [closed]

I will like to fix the issue where "git add" fails when a space is detected in the path file name. e.g source/code/data form/documents.txt. How can I update this script to allow file names ...
Ctan Li's user avatar
  • 187
-1 votes
0 answers
27 views

Bash Regex Start Anchor w/Character Classes Not Working [closed]

GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu) Copyright (C) 2019 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html $> var=39Q08a ...
Adam D.'s user avatar
  • 189
-1 votes
0 answers
36 views

apk not found/ apk doesn't exist - System App on Anbox Cloud Appliance

I'm trying to install an app as system app in anbox cloud appliance however it keeps giving me this error: "APK not found..." or it says "APK doesn't exist" with the given address. ...
Faraz2079's user avatar
-2 votes
4 answers
101 views

How to append some static content within a single cell of an existing CSV file

Let's assume I need to append the below content within the first cell (not be row by row) of the existing CSV file which has details of the customer. How can I achieve it? Content to be added: "...
Loganayaki mahalingam's user avatar
0 votes
0 answers
27 views

Run certbot on centralised server to generate certificates manually [closed]

Overview:- Developed a centealized custom api (.net) and deployed to nginx server to accept api request for generating a ssl certificate through api calls. when a new request api call is made , I’m ...
Yuvraj's user avatar
  • 11
1 vote
0 answers
70 views

exit status of if statement in bash when condition is false

If I run help if in bash then it tells me that the exit status is "the status of the last command executed". Let's try it: if false; then echo we never get here fi echo $? The last ...
Mark VY's user avatar
  • 1,639
2 votes
3 answers
70 views

Using sed to remove differences in two arrays (updated ssh keys)

My aim is to updated automate the update of ssh keys in the authorized_keys file. Due to restrictions i am unable to use ansible which would have been a lot simpler. Steps: read keys from the file ...
Drey''s user avatar
  • 25
0 votes
0 answers
27 views

Websphere Automation [closed]

I have a script which references a txt such as serverList.txt which has a list of linux servers where WAS is running and stops the nodeagent on them. I'd like to add to the script where it stops the ...
Engineer83's user avatar
-1 votes
5 answers
114 views

How do I delete all the lines that match and one after each of them?

I have a large file and a list of my specific strings. The output should not contain my specific lines and one more after each of them. 2 consecutive matches are impossible due to structure of file ...
Женя Гончаров's user avatar
0 votes
0 answers
27 views

In bash why does the increment operator set the exit code to 1 if the input is zero [duplicate]

In the following bash session you can see the ((cnt++)) sets the exit code to 1 if cnt is zero, but not if the initial value is anything else, why is this? $ cnt=0 $ echo $? 0 $ ((cnt++)) $ echo $? 1 $...
Damo's user avatar
  • 6,188
0 votes
1 answer
43 views

How to use REST API to delete message on Azure Storage Queue in bash?

I would like to know how to delete a message on Azure Storage Queue. Currently I keep getting the following error. <?xml version="1.0" encoding="utf-8"?><Error><Code&...
Xynanxdb's user avatar
-2 votes
1 answer
46 views

running command when program crashes [duplicate]

I have a Minecraft server that runs on Ubuntu 24 and mincraft1.21. Sometimes the Minecraft server file suddenly stops working and jumps back to the terminal. How can I write a Bash program that when ...
amir sobhan ahmadi's user avatar
0 votes
1 answer
37 views

Why does running a gzip command in combination with sponge in my Nextflow script produce an empty file?

I have a fairly simple nextflow process - it takes a file, does some simple processing, and uses sponge to write to the same file. At the end of the script, it uses gzip to compress the file. However, ...
Iced Coffee's user avatar
1 vote
1 answer
45 views

How to run a bash script using bash using Docker-in-Docker

I have a bash script that I use to build my Docker images and I'm trying to set up my GitLab CI so that it automatically builds the image whenever I push a tag. This is my .gitlab-ci.yml file: stages: ...
dokgu's user avatar
  • 5,718
0 votes
1 answer
27 views

Hadoop Truncating Strings at 256,512,1024 Characters Arbitrarily

this is my first post so apologies for any confusion. I am attempting to run a DNA sequence analysis through Map Reduce. Here are the important parts of my mapper.sh script: while read line do ...
user26492029's user avatar
2 votes
4 answers
73 views

How to change old date format in a file to a new format

I have a huge file, and it has around 200 lines like this: started at Wed Jun 5 08:45:01 PM +0330 2024 -- ended at Wed Jun 5 10:35:34 PM +0330 2024. started at Thu Jun 6 01:30:01 AM +0330 2024 -- ...
Saeed's user avatar
  • 3,895
-1 votes
0 answers
19 views

--include option in grep working different in .bashrc method [duplicate]

When I run grep -ril --include "gokp*" "blah" . --exclude-dir=deployBuild from a bash shell I get the following output: ./general/dbprocs/gokpve1.sql ./general/dbprocs/gokpven.sql ....
Shaun's user avatar
  • 1
0 votes
1 answer
53 views

How to evaluate 2 variables using bash arithematic in if statement with AND operator in bash shell [duplicate]

I have an alphanumeric string, say something like "XXXX24Y2" from which i have extracted only the numbers and assigned them to 2 variables, say num1 and num2, say num1=24 and num2=2 Now i ...
Aditi 's user avatar
0 votes
2 answers
34 views

Autorun with boot Raspberry Pi 4

I have such a problem I wrote python script and want to run it automatically with boot through shell script. I tried to add this .sh file to crontab -e in such way: @reboot /home/path/to/my_script.sh ...
Nazar Pankov's user avatar
0 votes
1 answer
87 views

Delete Pod without restarting other resources/object

I currently have this bash script that do cleanup obsolete resources for deployment, services, and configmaps. when I try to add the kubectl delete pod on the script, then it will delete all the ...
生きがい's user avatar
0 votes
0 answers
25 views

ssh into remote servers, get systeminfo and print out in local terminal [duplicate]

I have the following script and when I run it, I don't get the expected output to the local terminal. I am assuming it must be the variables that I am assigning in the heredoc that is not getting ...
JKC's user avatar
  • 25
0 votes
1 answer
68 views

C program called in a bash loop incrementally reading from a single file never exiting

int main() { char buf[2]; read((0, buf, 2); lseek(0, 1, SEEK_CUR); write(1, buf, 2); } The rwl program, whose source code is shown on the top, is run with the following command on a 2-...
Ozan Aykan's user avatar
0 votes
4 answers
88 views

Not getting the desired result in the shell script

I am trying to search a particular pattern "JOB" in all the files in the mentioned directories, and the checking if the next word after JOB has at least 5 characters and if the 5th character ...
raymond indwar's user avatar
0 votes
0 answers
31 views

while read - change global variable on bash linux [duplicate]

This simple code really confused me n=0 cat file.txt | while read line ; do n=1 done echo $n output >> 0 Why ???!!!!! Why does the public variable not change? I expect the value 1 to be ...
Omran's user avatar
  • 1
0 votes
1 answer
79 views

Batch "%1" and path spaces

On Windows I made a file called mingw64_open_with.cmd and associated .sh bash files so that they open with it, the goal being to be able to double click .sh bash scripts on Windows to run them through ...
Michel Rouzic's user avatar
0 votes
1 answer
42 views

How to set a bash variable with environment variables?

I have environment variables POSTGRES_USER=dbuser POSTGRES_PASS=dbpasswd POSTGRES_DBNAME=db POSTGRES_HOST=123.123.123.123 POSTGRES_PORT=5432 I want to use them in bash script to declare a variable #!/...
Nikko's user avatar
  • 1,542
0 votes
1 answer
36 views

How to get the size of files or compressed files inside a compressed file in Linux?

So, essentially I have a compressed file bootcd.tar.gz and it contains a bunch of directories, files and compressed files like (*.tar.gz, initrd.img etc). How do I calculate the total recursively ...
GuruRandapa's user avatar
0 votes
0 answers
35 views

When I try to add a new user by "useradd -c" inside while loop in Ubuntu24.04 doens't work, but at the other Ubuntu version the same script works

I'm a new student at the Linux Command and Shell Script and I'm reading the book called Linux Command Line and Shell Scripting Bible, Third Edition. In this book, on the 361 page, there is a script ...
Leonardo Teramatsu's user avatar
-1 votes
2 answers
42 views

VSCode CLI in bash script while loop to open multiple files [duplicate]

I'm trying to use VSCode cli code in a while loop in a Bash script to open a number of files, the names of which I'm reading from a text file. When I run the code below, it opens a file correctly for ...
Ben's user avatar
  • 5,489
-3 votes
0 answers
46 views

Linux clipboard: storing and retrieving MULTIPLE mime types (with Bash)? [closed]

I'm trying to build a script that will save the complete contents of the clipboard to a file and then restore it later. Unfortunately I have discovered that the clipboard frequently contains multiple ...
Gridzbi Spudvetch's user avatar
-1 votes
0 answers
37 views

How to exclude a particular column in a text file using UNIX "cut" command [duplicate]

Basically, I'm looking for the compliment of the current UNIX command "cut". If I have a text file as below "1" , "cat" , "animal" "2" , "parrot ,...
Mike's user avatar
  • 1,269
3 votes
1 answer
69 views

Making sense of the regex in grep command [closed]

When executing the following command in a bash shell: grep '^\(.\)*\1$' exp.txt I expect it to match any line that: begins and ends with the same latter. but in reality it matches the following ...
Balawi28's user avatar
  • 179
-1 votes
3 answers
73 views

Is it possible to force bash `read` to consistently read the requested number of Unicode characters? [duplicate]

Consider the following script, which attempts to read a fixed number of characters from a file containing Unicode using bash's read function, and then counts how many characters are read. MWE.sh #!/...
merlin2011's user avatar
-1 votes
2 answers
77 views

BASH: Assign values to variables with echo | sed | read [duplicate]

I'm trying to pass a string through a pipe going from echo to sed to read, but something isn't working: #!/bin/bash STR="alef|bet|gimel|daled" echo $STR echo $STR | sed 's/\|/ /g' | read ...
Akira Takeshi's user avatar
1 vote
0 answers
37 views

Access and Change settings on a TP Link Modem using curl or similar

I can't seem to find any working references or examples which would allow me to make changes to the settings in my Archer A23 WiFi router using any form of script. I've spent some time trying to get ...
monkey's user avatar
  • 1,518
-4 votes
1 answer
40 views

bash - renaming multiple folders using an excel sheet [closed]

I am trying to automatically rename several folders with temporary names ("634832483hdgfds") based on a list of real IDs I have been given (each real_name corresponds to one of these "...
spring-forest's user avatar
3 votes
1 answer
60 views

bash error message seemingly comes from environment instead of from bash itself when executing inside a function

Consider the following simple bash script cd nowhere This results in an error message something like my-script.sh: line 1: cd: nowhere: No such file or directory So far so good. This makes sense. ...
Mark VY's user avatar
  • 1,639
2 votes
2 answers
58 views

How to correctly plot special time format HMMSS?

Through the use of BASH scripts, I am pinging 50+ devices on a computer network, and tracking when these devices fail. Using sed and some other utilities, when a ping fails to return, it is recorded ...
CyberdocWI's user avatar
-2 votes
0 answers
18 views

Removing superfluous text from a temperature reading [duplicate]

I'm writing a BASH script to log the temperature among other things from various devices. Whenever I pass the temp to my logs it displays as the following format: +35.9Å°c I want to remove the Å and ...
Entropy1024's user avatar
  • 7,897
1 vote
0 answers
37 views

Redirecting python script's stdin to fifo results in RuntimeError: input(): lost sys.stdin

I have this python script that's meant to function as a server which reads commands from stdin which is redirected to a fifo: test.py: while True: try: line = input() except EOFError: ...
Verpous's user avatar
  • 706

15 30 50 per page
1
2 3 4 5
3124