Questions tagged [bash4]

is a Unix shell written by Brian Fox for the GNU Project as a free software replacement for the Bourne shell (sh). Version 4 was released on 20th of February, 2009.

Bash is a command processor, typically run in a text window, allowing the user to type commands which cause actions. Bash can also read commands from a file, called a script. Like all Unix shells, it supports filename wildcarding, piping, here documents, command substitution, variables and control structures for condition-testing and iteration. The keywords, syntax and other basic features of the language were all copied from sh. Other features, e.g., history, were copied from csh and ksh. Bash is a POSIX shell but with a number of extensions.

The name itself is an acronym, a pun, and a description. As an acronym, it stands for Bourne-again shell, referring to its objective as a free replacement for the Bourne shell. As a pun, it expresses that objective in a phrase that sounds similar to born again, a term for spiritual rebirth. The name is also descriptive of what it did, bashing together the features of sh, csh and ksh.

Source: Wikipedia [Bash (Unix Shell)]

79 questions
1
vote
2 answers

Bash calculator

The following line is not working in my script: a=$(echo "scale=3;(2*$j/(sqrt(3)*$i))" | bc) a1=$(echo `expr "scale=3; $a^(1/3)"` | bc -l) The error it is giving: Runtime warning (func=(main), adr=21): non-zero scale in exponent I just want to…
1
vote
1 answer

bash4 - creating array of directory contents on regex filter

Looking for a way to create an bash array based on a regex in filtering a directory. For example I do: A. local -a arr=( "$1"/* ); arr=( "${arr[@]##*/} ); - Creates array of all contents of the path sent in $1. B. local -a arr=( "$1"/*"$2" ); arr=(…
mono-dr
  • 217
  • 1
  • 2
  • 9
1
vote
1 answer

Bash: process substitution inside a string

In bash if I type a command foo bar <(qux) it will launch the foo program and its parameters will be bar and /dev/fd/63 (or something like that). If I type a command foo "bar <(qux)" it will launch the foo program and its parameter will be bar…
etam1024
  • 843
  • 1
  • 7
  • 17
1
vote
2 answers

Iterate over several associative arrays

For my current use case I'm creating an scp script which will copy log files from one server to one or more other servers. I.e. server1:/my/path1/log-files.* --> log_server1:/log/path1/server1 server1:/my/path2/log-files.* -->…
sastorsl
  • 2,015
  • 1
  • 16
  • 17
1
vote
1 answer

Bash - POST : send image in message content

I would like to send POST message using bash script.In body there should be image but i don't know how to put them.
0
votes
1 answer

BASH how can i get other scripts output, in the active dialog box?

I have a dialog window using ncurses. But in that dialog window i want to show my driver.sh outputs, how can i do that? Or at-least something like its complete or not complete. 1) /tmp/main.sh if [ "$output" = "1" ]; then # here in this window…
user285594
0
votes
2 answers

How can i get the realtime values to make my own script in BASH specially as shown the attachment

I am trying to write in BASH my own tracking such as shown in the attachment. Specially i need to track the Network History Recieving and Sending data. Where i can get those Network send/receive values, is it in a file or is that comes out from…
user285594
0
votes
2 answers

How do I add newline character at end of lines in blockquote for printing?

I'm using MacOS and Bash 4.4.23. I want to be able to have a long blockquote in a single string for a help dialogue and print that in the program. Suppose I have a string in var help help='Searches a user to see if he exists.' help2='Searches a…
James T.
  • 910
  • 1
  • 11
  • 24
0
votes
2 answers

How to use key and value in a `borg create` command using for loop(or not)

I have some sites on a server and I want to only backup their webroots creating a new repository for each site. With bash 4 I can use a dictionary. declare -A sites=(["site1"]="/var/www/webroot1" ["site2"]="/var/www/webroot2" …
Vasiliki
  • 143
  • 9
0
votes
1 answer

Strange bash message when source-ing file

ql_get_latest(){ . "$BASH_SOURCE"; } export -f ql_get_latest; when I run bash, I drop into a shell: and then when I run ql_get_latest I get: bash: environment: No such file or directory anybody know what that's about?
user5047085
0
votes
1 answer

illegal character found in url

I'm trying to extract data from an api with different ids stored in a text file but i keep getting the message "curl(3): illegal character found in url". the text file…
0
votes
1 answer

SNMP Network script

I'm looking at building a SNMP monitoring script that gets each packet value from each port on the switch via SNMP. Unfortunately, the script I have appears to give me errors where the variables are. oldin-1=1: command not found Does anyone know…
0
votes
1 answer

bash 4.4 inside python with os.system

I have problems with running a bash script inside a python script script.py: import os bashCommand = """ sed "s/) \['/1, color=\"#ffcccc\", label=\"/g" list.txt | sed 's/\[/ GraphicFeature(start=/g' | sed 's/\:/, end=/g' | sed 's/>//g' | sed…
rororo
  • 815
  • 16
  • 31
0
votes
1 answer

How to parse CSV file for long row in Bash?

I have IDs in the first column of data.csv with headers. I want to skip the header and store column 1 values in the variable ids as 102 103 104 .... Pseudocode in the line ids.append($col1) where I want to append the current row value to the end…
Léo Léopold Hertz 준영
  • 134,464
  • 179
  • 445
  • 697
0
votes
2 answers

Bad substitution?

I'm having what seems like a pretty simple problem that I can't seem to fix, and the only help I'm getting from bash is that it's a bad substitution. Any help? #!/bin/bash lang=Python frameworks=('Python=(Django Flask Pyramid)' 'Ruby=(Rails…
user5359735