Skip to main content

Questions tagged [bash]

Questions specific to GNU’s Bourne Again SHell, as opposed to other Bourne/POSIX shells. For questions about Unix shells in general, use the /shell tag instead. For shell scripts with errors/syntax errors, please check them with the shellcheck program (or in the web shellcheck server at https://shellcheck.net) before posting here.

2votes
1answer
48views

Using mapfile on the output of another command [duplicate]

I want to edit a file before feeding it into an array. The data file contains: Line 1 Line 2 Line 3 If I read it with mapfile -t direct < data I obtain a 3-element direct array But I pipe the ...
xenoid's user avatar
  • 9,248
-4votes
0answers
49views

Creating in Linux files in GB or MB range by various random size by read a file [closed]

In Linux in Bash i have this script (thanks to Ed Morton) . $ cat ./tst.sh #!/usr/bin/env bash while read -r idx sfx size; do echo fallocate "file${idx}.${sfx}" "$size" done &...
user447274's user avatar
0votes
1answer
47views

How to make bash not set the underscore _ environment variable?

How to make bash not set the underscrore _ variable for the processes that it's starting? Explanation of what it is if you haven't encountered it before: If you launch env from bash, you'll see the ...
VasyaNovikov's user avatar
0votes
0answers
38views

Understanding `bash` options -Ee

In a larger script I have trap -p echo "settings: [$-], command: [$*]" "$@" echo "return code $?" and I get the output trap -- '_shunit_cleanup EXIT' EXIT trap --...
Harald's user avatar
  • 1,030
6votes
4answers
518views

Using curly braces to process colon-separated variables

If we do: VAR=100:200:300:400 We can do: echo ${VAR%%:*} 100 and echo ${VAR##*:} 400 Are there any equivalents I could use to get the values of 200 and 300? For instance, a way to get only what's ...
Cestarian's user avatar
-2votes
1answer
108views

Creating in Linux files in GB or MB range by various size by read a file [closed]

In Linux with Bash, there is the File numbers_in_one_line. In this file there is only one line with several numbers, all separated by spaces. These numbers are the value in bytes for creating files ...
user447274's user avatar
-1votes
2answers
79views

Counting unique IP addresses per hour in existing log files

I am trying to determine the number of unique web visitors to my website each hour. The log files (access*.log) contain many lines looking similar to this. 192.168.211.85 - - [29/Sep/2024:10:17:02 -...
kojow7's user avatar
0votes
1answer
44views

Where to set XDG_RUNTIME_DIR per user?

So I ran into the following interesting problem: I tried to define XDG_RUNTIME_DIR in my .bashrc as follows: export XDG_RUNTIME_DIR=$MY_HOME/.local/share After doing this I noticed my pactl cli ...
glades's user avatar
0votes
1answer
68views

bash - list of breaking change

I know bash tries very hard to keep new versions compatible with previous ones. However they sometime introduced (minor, but still) breaking changes: for exemple when we could no longer have : { foo }...
Olivier Dulac's user avatar
2votes
1answer
52views

Why can't I have a single quote in a bash associative array index when testing with `test -v` [duplicate]

When I run the following code declare -A X # get an associative array index="a'b" # a somewhat weird index X[$index]="this is set" echo "<<${X[$index]}>>" if ...
Harald's user avatar
  • 1,030
14votes
1answer
3kviews

Why does cd '' succeed in bash?

Maybe I'm missing it, but I don't find it documented that cd '' should succeed. Since there is no directory with the name '', it seems obvious that it should fail. For example, mydir= cd -- "$...
jrw32982's user avatar
0votes
2answers
80views

How does `*\ *` work in bash?

There is an answer from SuperUser, which renames filenames containing whitespace: for f in *\ *; do mv "$f" "${f// /_}"; done The part I don't understand is *\ *. The author wrote ...
glacier's user avatar
2votes
1answer
184views

Using Here-Document as password Input for ssh

First, I do know this is a security risk. I do know about ssh keys and sshpass. This belongs to a fun project. I wondered if a bash Here-Document could be used as a password input for ssh. I ...
Simon Huenecke's user avatar
-3votes
1answer
96views

bash -n is a not documented in manpages or info documents [closed]

Even though bash -n is a valid and widely used option, some manpages don't clearly document it in the bash options section, even though it is implemented. It's also not in the GNU Bash Reference ...
bit's user avatar
  • 1,166
5votes
6answers
1kviews

Why can't I merge folders by renaming one of them?

Try to run this mv -- "foldername...__" "foldername..." This will move folder foldername...__ under the folder foldername... instead of renaming it. Why? Note that foldername... ...
Estatistics's user avatar

153050per page
close