Skip to main content

All Questions

Tagged with or
0votes
0answers
18views

Why is set -e also ignored for functions called via command substitution [duplicate]

I've seen questions about this topic, but they talk about constructs like if or ||. I don't understand why the same behavior seem to happen for substitution ($())? $ my_function() { echo "the ...
Jakub Bochenski's user avatar
1vote
0answers
44views

How to pretend to not run the command in a TTY [duplicate]

I have a command (systemctl status) that halts and waits for keystrokes if I run it in a terminal that is not tall enough. I'm not interested in this behavior and can't find an option to bypass it. If ...
xenoid's user avatar
  • 9,258
0votes
3answers
52views

Making each word in a text file an item in a bash array

I have a string of text and spaces which looks like this: macOS windows arch-linux ubuntu_linux I want to append each item (with whitespace denoting a break between items) to a bash array. How do I ...
EmberNeurosis's user avatar
0votes
1answer
47views

Find and remove spaces in files and folders, then find patterns in files, then copy the files found

First I will describe the task I have: I have several disks I have a list of phrases (words) in a patterns.txt file that I use as search patterns I must to review the disks in search of files ...
DarekH's user avatar
2votes
1answer
56views

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,258
-4votes
0answers
56views

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
54views

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
40views

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
685views

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
111views

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
84views

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
47views

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
69views

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
55views

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

153050per page
close