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.

0 votes
1 answer
25 views

How to modify this git alias so it can be run without the need to put multiword commands in quotation?

I have this alias: git config --global alias.all '!f() { ls -R -d */.git | xargs -I{} bash -c "echo {} && git -C {}/../ $1"; }; f' It currently works fine when I run it like : git ...
Codrguy's user avatar
  • 123
0 votes
2 answers
56 views

Regarding Nested loops

I had 3 array array1, array2, array3 where array 3 is the value of first two array. for example: FO=2.0, FF=3.5, FC=4.5 and so on. I want to give k (third loop) values of array3, like while running FO ...
Khushi's user avatar
  • 1
0 votes
0 answers
14 views

macos/bash: read "hangs" when executing script second time as another user with stdout redirected before

Hello! My second file descriptors question. Context: Still new at this, I certainly don't get file descriptors. Magic. Unpredictable magic at that, that sometimes works. (joke, but you probably get my ...
Marcus Widerberg's user avatar
0 votes
0 answers
17 views

Looping ssh command with `while` stopped at first iteration but not `for` [duplicate]

The following didn't work: cat /etc/hosts | grep -vE '(^(#|$)|127.0.0.1|ff|::|node)' | awk '{print $1}' | while read -r host; do echo "Looking at $host" ssh "$host" ...
annahri's user avatar
  • 2,075
1 vote
0 answers
18 views

While Loop Exits After Calling Function [duplicate]

I'm trying to do a db backup script using Bash. When adding a "Resume" feature to the script, I do the following loop calling defined functions to do step by step (depending on the .lock ...
James's user avatar
  • 111
0 votes
1 answer
38 views

basename complains about missing operand using unshare

If I try to create namespaces, basename complains about missing operand: sudo unshare --mount --ipc --uts --pid --fork --user /bin/bash basename: missing operand Try 'basename --help' for more ...
sebelk's user avatar
  • 4,469
-2 votes
1 answer
59 views

How to convert multiple columns to rows in shell (unpivoting)

I have a tab separated table with hundreds of columns and rows, like that: OTUId AC0184 AC0250 AC0257 AC0258 AC0262 AC0263 AC0289 AC0293 OTU549024624 51659 0 0 0 0 0 0 0 OTU565712448 108 0 0 0 0 0 0 0 ...
babinecha's user avatar
-1 votes
1 answer
55 views

Why doesn't 'export' give the export attribute while 'set -a' does?

From man bash (GNU bash, version 5.2.21(1)-release (x86_64-pc-cygwin)): set [-abefhkmnptuvxBCEHPT] [-o option-name] [--] [-] [arg ...] -a Each variable or function that is created or modified is ...
pmor's user avatar
  • 619
0 votes
1 answer
44 views

How can I get stderr from mbuffer written to log file when using tee?

Having a bash script that essential only doing: mbuffer --md5 -i dummy.tar -o /dev/null A user of this script wants to use tee and store the output messages in a log file. ./script.sh 2>&1 | ...
TopCatSE's user avatar
2 votes
4 answers
330 views

output of a command framed by a couple of '#' characters

I want to be greeted by # ##################################################### # ### PostgreSQL 16.3 ################################# # ##################################################### on ...
vrms's user avatar
  • 161
0 votes
1 answer
36 views

tar returning different exit code when wrapped inside if statement [duplicate]

I have a script which creates a tar archive filtered through xz. I have wrapped the tar command inside an if statement so the script can take different actions depending on whether the archive was ...
mongotron's user avatar
1 vote
2 answers
74 views

How to append multi-line text with spaces to end of file if that text does not exist in bash?

I'm trying to append a text string that contains newlines and spaces to a file if the whole string doesn't already exist in that file. Ideally done in a way that's portable across MacOS and Linux I ...
David Alsh's user avatar
0 votes
0 answers
17 views

How do I determine if a path is a fifo? [duplicate]

I have some bash shell code that runs if [[ ! -s "$1" ]] to determine if $1 is a non-empty file This test fails if $1 is a fifo, even though the fifo has data in it ready to be read. Is ...
Greg Dougherty's user avatar
-1 votes
3 answers
90 views

Delete 2-line paragraphs, keep 3-line paragraphs, maintain newline between all

On a Linux machine with GNU tools I have an ascii file that consists of only 2-line and 3-line paragraphs, each paragraph separated by a newline. All 2-line paragraphs are to be deleted so that all 3-...
stampeder's user avatar
3 votes
1 answer
40 views

Is it normal for "complete -p git" to error until I autocomplete git first?

If I restart my terminal, I get an error when I type this: $ complete -p git bash: complete: git: no completion specification But if I type git tab then run the complete command again, I get a ...
Daniel Kaplan's user avatar

15 30 50 per page
1
2 3 4 5
1742