Questions tagged [bash]

For questions about scripts written for the Bash command shell. For shell scripts with errors, please check them with the shellcheck program (or in the web shellcheck server 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 Les Vesti.

0
votes
0answers
3 views

Running Make to compile Bash returning error

When I run "make" on my Mac 10.13 to compile Bash, I get this error: make: *** [y.tab.c] Error 1. What does it mean and how do I solve this? Full output: bison -y -d ./parse.y ./parse.y: warning: 1 ...
0
votes
1answer
6 views

How to print lines between a pattern and a line starting with another pattern?

I need your help in parsing a log file with AWK (preferably) in order to extract only the necessary information. I simplified it a lot to be more visible, and it looks like this: 2019-05-22 HH:MM:SS ...
0
votes
0answers
19 views

How to make awk print one of 2 different fields based on which of it matches the condition

I have a ascii table in Linux which would look like this: Oct Dec Hex Char Oct Dec Hex Char ------------------------------------------------------------- 056 46 2E . ...
0
votes
0answers
9 views

Running “pod install” in automator action in Mac OS - Permission denied

I am currently grading approx 50 apps created by students whereas most of them use CocoaPods in their projects and I'm spending an awful lot of time just navigating in the terminal to different ...
0
votes
0answers
12 views

Can not load local dir Node.js modules when using --input-type

Node.js 12+ has new command-line option --input-type to run script inside Bash heredoc. However, it doesn't seem to be able to find Node.js modules installed in ./node_modules Here's how I install a ...
0
votes
0answers
15 views

Is there any way to know the bytes that have been sent/received by serial port in bash?

I need to know the quantity of bytes that are sent or received in a certain time via serial port, in bash. It may be something similar to /sys/class/net/eth0/statistics/rx_bytes in ethernet. How can I ...
-1
votes
0answers
23 views

Problems with Shortest Job First (SJF) and Round Robin (RR) scheduling plus Gantt Chart in Bash Unix Shellscript

I want to simulate CPU scheduling algorithms using Unix Shellscript but the code doesn't work when the shell script is executed. Most of the code is translated from C and I can't figure out on how to ...
-3
votes
1answer
31 views

Need help executing binary file on bash terminal with -wall -pedantic -ansi flags

Cannot execute program on Visual Studio Code terminal on Windows with -Wall -pedantic -ansi flags. The program for assignment right now is just a simple "Hello World" main in C with a struct I've ...
0
votes
1answer
23 views

Generate a file from a loop

How would one write a script that would create a file that is called post-data.txt that would contain 3000 records of json data as follows: {"firstName":"random_string_of10_characters","lastName":"...
3
votes
1answer
25 views

Can a shebang refer to a remote program?

Is it possible to add a shebang line to a file so that it refers to a program on a remote machine? For example I don't have wolframscript installed on my local machine, but I do on a remote machine. ...
0
votes
0answers
20 views

Compare array elements and determine which element's string is the part of another in bash

I have an array: src_dir=( /etc /var/www /var /var/html /home/user) I want output like this: /etc /var contains /var/www /var/html /home/user I've tried so far: src_dir=( /etc /var/www /var /var/...
-1
votes
0answers
9 views

How to write a shell script to install nvm and nodeJs?

for some reason I need to write a shell script to install nvm and nodeJs. I know how to do it at command line curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.0/install.sh | bash . ~/...
0
votes
0answers
13 views

Why I am not getting a value when i call a function within another in a bash script

I have a function that generates a random file name generate random file names get_rand_filename() { if [ "$ASCIIONLY" =="1" ]; then for ((i=0; i<$((MINFILENAMELEN+RANDOM%MAXFILENAMELEN)); ...
0
votes
2answers
16 views

How to switch between gcc6 and gcc8 based on a variable in powershell

I am trying to switch between gcc-6 and gcc-8 based on a variable in a powershell script. I have both installed and my ~/.bashrc file is empty. I have in script.ps1 $gccVersion ='gcc8' if ($...
0
votes
0answers
15 views

Is there a way to delete json files produced by protractor cucumber on Jenkins when using protractor flake?

I'm running protractor flake on Jenkins for automation testing using the framework protractor cucumber. Each time the tests run, a json is outputted. Is there a way to delete the old json output or a ...
0
votes
0answers
8 views

How to initiate multiple python scripts using detached screen processes with a python script

I'm trying to run multiple python scripts in detached screens. I'm creating a python script to initiate each screen session but they do not run. I think it has to do with subprocess.Popen. The command ...
0
votes
0answers
19 views

Executing bash code interactively using -c flag (With |& and gnu screen)

Before we get into the weeds: I'm choosing to use screen as a very crude multithreading tool. This is because I like screen, it's everywhere I care about, and it suits this purpose. I'm trying to ...
0
votes
2answers
19 views

How to use AWS CLI to deploy lambda function to specific alias or version?

Before I have Lambda version and alias, based on the API update-function-code I can successfully deploy by aws lambda update-function-code --function-name myFunction --zip-file fileb://archive.zip ...
1
vote
1answer
25 views

field is immutable k8s

I am trying to deploy an application to GCP on kubernetes, however, the deployment fails with the error the job spec is invalid ... the field is immutable. In the migration job, I have a section of ...
2
votes
1answer
43 views

Why does “. myscript” return file-not-found in only one Git for Windows sh.exe?

I have downloaded Git from here. I recently discovered there's two copies of sh.exe, which provides a bash shell. C:\Program Files\Git\bin\sh.exe C:\Program Files\Git\usr\bin\sh.exe I have come to ...
-4
votes
0answers
20 views

creating a file date.txt and writing dates in it which fall between argument1 and argument2 include both. unix/linux

have to create a unix/linux/shell-scripting file abc.sh passing date1 and date2 as 2 arguments, it should create a file in john/date.txt and write date1 to date2 dates in it and each date should come ...
0
votes
0answers
13 views

How to use 'kubectl cp' with bash variables [duplicate]

I trying to automate copying files from a kubernetes pod with a shell script. I am getting unexpected errors while using shell variables. I am able to populate shell variables using the following ...
0
votes
2answers
26 views

Select files numbered like “file.00001” to “file.00431” for instance

I would like to select files named like : "file.xxxxx". Each x can go from 0 to 9. For instance, I used this piece of code for files file.0000x #!/bin/bash for i in {1..9} do [...] file.0000${i} &...
1
vote
1answer
36 views

How to parse a rdf format file from command line

I'd like to parse the install.rdf file inside the uBlock0.firefox-legacy.xpi file. I want to get the em:id, em:name, em:version, em:description and em:homepageURL from the install.rdf file like this :...
1
vote
1answer
49 views

How to delete first n characters from each first line of multiple files using bash? [duplicate]

I have big number of exports. All files have same structure. I need to remove first 15 characters from each first line in each file in the same directory. I tried this piece but this removed first 15 ...
0
votes
1answer
27 views

bash script infinite loop one line syntax

I have a simple bash script which reads from a file, line by line and prints it to the screen (adopted from another SO answer). while IFS= read -r line || [[ -n "$line" ]]; do echo "$line"; sleep 2; ...
1
vote
1answer
25 views

Run shell command in parallel and wait for result

I want to run command_a and command_b in parallel, and wait for both of them finishing to start another command_c. Is there a simple command/idiom in shell that allows me do that? Thanks!
0
votes
1answer
36 views

Is it possible to list files that match a pattern with ls?

I want to list files of a directory with ls that match a pattern without using grep. Is it possible? The point is to retrieve all files that match this pattern '^\Extra_text_[0-9]\{10\}.csv' and ...
0
votes
1answer
26 views

Calling rsync in bash from Windows cmd

I am trying to run rsync from a batch file. The command is SET CMD="rsync -P -rptz --delete -e 'ssh -i /root/.ssh/CERTIFICATE.pem' SOURCE_ADDRESS /mnt/c/Users/MYNAME/IdeaProjects/PROJECT/SUBFOLDER/...
0
votes
1answer
39 views

Unknown shorthand flag: 'd' in -d

I am trying to pull a docker image using the following command. It was suggested that I run this as a guide for docker config at my workplace. Tried removing the -d out of the command, but now I get ...
2
votes
4answers
35 views

Merging two consecutive lines into one (seeking a solution working for Windows files too)

I'd like to merge two consecutive lines in a Windows text file using external bash environment like the one that for instance Cygwin or MobaXTerm provide. I know there are similar questions asked and ...
0
votes
1answer
20 views

Search curl output for string with Bash

Trying to fetch a webpage as a lowercase string, then search the string output for a substring My attempt: 1 #!/usr/bin/env bash 2 3 URL="https://somesite.com" 4 MOVIES_SOURCE="movies.txt" ...
1
vote
2answers
44 views

Function to produce random number between 0 to 50

Below is the code i thought would create a random number between 0 to 50(Both included) #!/bin/bash var1=51 var=$RANDOM echo $var function rand(){ local var1=$1 local var2=$2 local result=...
-1
votes
1answer
24 views

How to execute shell script with sudo from java backend?

I can't figure out how to execute a command like sudo some.sh from a java backend. The sudo is pwdless. I tried with exec() and with builder without any luck (see below). If i try passing exec("sudo ...
1
vote
3answers
26 views

Why does a pipeline reading from and writing to the same file result in a blank file? [duplicate]

I have a text file with some lines I'd like to sort. This file is named somefile. cat somefile | sort results in some sorted output being sent to stdout. cat somefile > anotherfile results in ...
0
votes
1answer
16 views

Splitting wireshark large size with pcap splitter with bash

I have large pcapng files, and I want to split them based on my desired wireshark filters. I want to split my files by the help of bash scripts and using pcapsplitter, but when I use a loop, it always ...
0
votes
1answer
25 views

Bash Menu - Return to Main Menu from SubMenu?

I've got a simple Bash Menu here. Everything seems to work great, except I can't figure out how to get back to the Main Menu from my SubMenu. Upon executing the script, I select "3" to go into the "...
1
vote
0answers
22 views

Check opened WAN ports via script matching iptables and netstat?

I'm trying to understand if there is the possibility to understand opened WAN ports on different devices that i can't connect to the internet and i can only scan by matching netstat and iptables rules....
0
votes
1answer
32 views

Parsing through output

I would like to capture Virtual IP values and store them in variables from the output below. There could one or more Virtual addresses associated with an interface. (192.168.1.1,192.168.2.1,192.168.3....
0
votes
1answer
30 views

Why does my bash script think an argument is not present?

I am trying to write a simple bash script that would execute as follows $ ./export.sh -n <my-file-name> -a <my-api-key> I am using this as a way to pass some arguments at build time in a ...
0
votes
1answer
20 views

replace only strings that are nested beside non-numbers

I am using the following bash code using sed to replace all instances of "600" with "123" in a HTML file: sed -i '' -e 's/'\"600\"'/'\"123\"'/' index.html I would like to extend the search to target ...
3
votes
1answer
50 views

Why does grep results in different results when used in script or in command line - when trying to find pid?

I'm trying to find the PID of Kibana process running on my Centos7 machine. I have a script that finds the PID by running the following line: kibana_pid=$(ps -ef | grep elk | grep kibana | awk '{...
0
votes
1answer
36 views

shell - Pass command line arguments to bash script does not work

I have a .sh script file and specifically the atguments are not going well, and I do not know the reason --engine = slimerjs and - headless #!/bin/bash xterm -e /usr/local/bin/casperjs --engine=...
0
votes
0answers
14 views

How to resize a composition image using bash in Imagemagick and Facedetect

Just working on adding smiley faces to lots of different costumes using face detection (Facedetect) and Imagemagick. I got the smileface to be composited to the suited people using composite, but the ...
0
votes
1answer
14 views

how to replace substitute string in cloudbuild.yaml

how to replace substitute string in cloudbuild.yaml? I want to set appengine version as $TAG_NAME with cloudbuild. Since the version only accept hyphen, I need to replace the dot to hyphen first. I ...
1
vote
2answers
34 views

Creating an array from file and name it based on a line in bash

I have text file like this: src_dir=source1 src_dir=source2 dst_dir=dest1 whatever_thing=thing1 whatever_thing=thing2 I want a script that will create arrays with names from the left part of a line ...
0
votes
1answer
43 views

Is there any way to read text file and use words inside it as input?

I'm dealing with one task where I have to read the text file and take every word present in it as input & the important thing is I should have to do it by using while or any other loop (Without ...
0
votes
0answers
14 views

PM2 status always “errored” when run bash curl cron

I use pm2 to manage the process. I have the bash script name "check.sh" that post to a URL curl -i -X POST https://postman-echo.com/post --data "This is expected to be sent back as part of response ...
1
vote
1answer
24 views

How can I limit readonly variable scope to a function?

I'm defining functions in a script with readonly local variables like this: test.sh function test_function() { readonly local foo="bar" } Before sourcing, foo is of course undefined $> echo ...
0
votes
1answer
27 views

Bash script to write all occurrences of application crash to a text file

I can't find how to structure my while loop properly to log to a text file all crashes of a given Linux application. I would like to get a prompt so I can input the application name and then a loop to ...

http://mssss.yulina-kosm.ru