Skip to main content

Questions tagged [bash]

Bash is a free shell for Unix-like operating systems from the GNU Project.

0 votes
0 answers
18 views

Script that checks whether agents running on workstation need idea where to write output [closed]

I want to write a script that checks whether specific software is running on a computer, i manage around 200 computers and I think this is the best way to check whether the necessary security agents ...
Lukas Yčas's user avatar
0 votes
0 answers
13 views

Task Scheduler Running Multiple Instances

I am encountering an issue with Task Scheduler on a Windows Server. I have a startup task that runs a program/script via Git Bash, which points to a .sh file that executes a Python script every minute....
matheww's user avatar
0 votes
0 answers
20 views

How to configure XShell so that PgDn work properly in bash?

The key PageDown types a ~ in my bash session instead of showing next command. Why does this happen and which settings do I need to change? In vi key works as expected. I did as described in How to ...
M-A-X's user avatar
  • 99
0 votes
0 answers
30 views

How do I determine which line has too many arguments within the script itself?

When I run the script I get the following errors: ./A_High_Stakes_investigations.sh: line 11: [: too many arguments ./A_High_Stakes_investigations.sh: line 11: [: too many arguments ./...
user2068890's user avatar
0 votes
0 answers
11 views

How to apply Postfix milter *before* smtp_generic_maps for DKIM purposes?

My Postfix instance instance correctly signs outbound mail with DKIM when I set the myhostname parameter to be the domain I wish to send from, say domain1.com. The issue I have is I have multiple ...
BrownianBridge's user avatar
1 vote
1 answer
15 views

bash autocomplete custom script with possiblities from a text file

I have a shell script that I want to run that accepts one argument (it's actually a short hostname). All of the legal hostnames for that script are stored in a plain text file, one entry per line. I'd ...
Blistering Sheep's user avatar
0 votes
0 answers
61 views

How to pass a for loop commandline argument to kubectl exec shell when run over ssh

I am executing the following commands over ssh and then past it to kubectl exec. ssh -i 'path\to\file' user@host 'kubectl exec -i pod-name -- bash -c "du --max-depth=1 /home -h -t 10M | sort -hr &...
G.Ybamit's user avatar
2 votes
1 answer
47 views

In which cases outputs of basename "$x" and echo "${x##*/}" differ?

In the following case outputs of basename "$x" and echo "${x##*/}" are not differ: $ x=xxx/yyy ; basename "$x" ; echo "${x##*/}" yyy yyy In which cases (if any)...
pmor's user avatar
  • 368
1 vote
1 answer
25 views

How to run sendmail as another other user?

I am witnessing behaviour I cannot explain. If I run sendmail as another user by executing the following commands seperately - that is, typing each command and pressing enter before entering the next: ...
BrownianBridge's user avatar
0 votes
0 answers
21 views

Wrapper to monitor CPU and memory usage for a command line without knowing its duration in advance [duplicate]

This great (in my opinion) answer on Super User provides a solution to track CPU and memory usage of a command line. It is great, however, you need to know in advance the duration of your command line....
JKHA's user avatar
  • 189
0 votes
0 answers
205k views

What does Bash command //xxx[] do? [closed]

I accidentally forgot to (double) quote $pat (should be echo "$pat"): $ pat="//xxx[]" ; time echo $pat //xxx[] real 0m4.704s user 0m0.000s sys 0m0.016s $ bash --version ...
pmor's user avatar
  • 368
1 vote
1 answer
34 views

how do I format the wildcard inside the BOOLEAN expression so that it tests for all extensions?

I'm trying to sync two directories, Masters and Proxies, via a bash script: # Loop through files in Proxy Files folder for file in "$ProxyFilesDir"/*; do # Extract filename without ...
Tom S's user avatar
  • 35
1 vote
1 answer
44 views

How to Preend or Append File Name to Reflect Number of Pages in PDF using "qpdf" and "perl"

I am running the script at the bottom as a one-liner but have expanded for ease of reading. Assume the directory contains the following file: File (11).pdf. When the script executes, it simply repeats ...
Brian's user avatar
  • 1,045
-1 votes
0 answers
48 views

Letter "b" in terminal doesn't work only in terminal and other letters is fine in Parrot OS

In Parrot OS when I try to write "bash" for example it's written ^[[1;5Dash letter b in terminal displays as ^[[1;5D and this just happens in terminal in any other app it works: In other ...
Muhammad Yasser's user avatar
1 vote
1 answer
116 views

Using sed to edit filepath variable

I am trying to use the sed command to edit a value in the .git/config file. When running the remote origin command, the config file creates the line of text like this": url = https://github.com/...
Abbatrombone's user avatar
0 votes
0 answers
10 views

Start vlock as a screensaver on console only debian

I am using a revived Chromebook as a secondary laptop. The eMMC is mostly fried, but I have a UEFI grub settup that boots Debian from an SD card. It is console only - no X11, etc. I can get the screen ...
Peter Weston's user avatar
2 votes
0 answers
40 views

Why is GNU wget only returning an index.html.tmp file, instead of the actual files I want?

I want to download a lot of satellite data (organized by each day of each year) in .hdf format from NASA's LAADS DAAC archive. They have a helpful guide that provides a code sample to use with GNU ...
Seyong Chang's user avatar
0 votes
1 answer
56 views

Desktop shortcut with a command line argument which contains filename with random numbers

I'm trying to create a desktop shortcut which launches a terminal app with commandline arguments which contains a path to a file with a randomly generated number in the filename. I've tried everything ...
zyntrax's user avatar
1 vote
0 answers
34 views

Set background colour in Windows Terminal, with git bash ANSI escape OSC 11 doesn't work

How do I get git bash to set terminal background colour using OSC Ansi Escape sequences? printf %b '\e]11;rgb:30/00/00\a' It works when I do it from WSL bash and for some servers when I ssh to them ...
Badger's user avatar
  • 51
1 vote
1 answer
45 views

SSH from A through B to C, using private key on B

Schematic: ssh ssh A ------> B ------> C ^ ^ using A's using B's ssh key ssh key Preconditions: A is running ssh-agent A can access B B can access C A can't ...
J.Nexus's user avatar
  • 11
0 votes
1 answer
35 views

How to detect even or odd minutes in bash script

I need to detect whether the current minutes are even or odd regardless of the time zone. I tried this according to answers from several sites: #!/bin/bash n=$(date +"%M") r=`expr$n%2` if [ ...
freetoair's user avatar
0 votes
1 answer
38 views

exit code segment causes Bash prompt to freak out

My Bash prompt (based on mike kasberg's) generally works fine. But when I get an error code, and then write over to the next line, no newline is generated, so the text goes back over my previous ...
Smiley Tiger's user avatar
1 vote
0 answers
29 views

How to Identify and Terminate Idle tmux Sessions on a Debian Server

I have a Debian server with multiple tmux sessions running. Some of these sessions are idle and not running any active processes. How can I identify and terminate all tmux sessions that are not ...
maxime de smedt's user avatar
1 vote
1 answer
20 views

Does bash support variable substitution in return statement?

Does bash support variable substitution in return statement? From man bash: return [n] Causes a function to stop executing and return the value specified by n to its caller. Is n allowed to be ...
pmor's user avatar
  • 368
2 votes
1 answer
85 views

Provide argument while starting a service using systemctl

I have a service installed on an old server and it is started using; service load-simulator start medium The value medium acts as a profile of sorts. It can have values like low, medium, high, and ...
Rajkishan Swami's user avatar
1 vote
1 answer
38 views

ssh -t host1 ssh host2 "cat < /tmp/test.txt" – file not found

I'm trying to run cat < /tmp/test.txt on remote host host2 through host1. The file /tmp/test.txt exists on host2. I try: # locally ssh -t host1 ssh host2 "cat < /tmp/test.txt" The ...
Daniel YC Lin's user avatar
3 votes
2 answers
447 views

bash see if element inside array is inside a different array

I am trying to test to see if an element inside an array exists. A test case is array1=(a b c) array2=(c d e) for ((i=0; i < ${#array1[@]}; i++)); do if [[ ${array1[$i]} == "...
Abbatrombone's user avatar
0 votes
1 answer
24 views

Font size issue with xterms started through icewm's hotkeys

Recently got a new laptop with 1920x1080 monitor instead of 1366x768 on old laptop. All my many xterms suddenly smaller and text illegible. After investigation, decided easiest solution was an alias ...
user985675's user avatar
0 votes
1 answer
28 views

Dealing with whitespaces in file names after git grep -l

I'm trying to run the script below and I'm struggling with pathspec error when the filename has whitespaces. I have already read some other posts around here, but since I am not an expert I was not ...
O Pardal's user avatar
  • 103
0 votes
1 answer
71 views

How to transfer a file to a remote host using parallel + ssh?

I am writing scripts to poll a large number of remote hosts over ssh using gnu parallel. I copy the script to them, run it and get the results. Right now I'm using two bundles parallel + scp to ...
Дмитрий Брыкалов's user avatar
1 vote
1 answer
95 views

How to merge all mp3 files located in the same directory?

The command below used to work but stopped around ubuntu/kubuntu 20.04. ls *.mp3 | sed -e "s/\(.*\)/file '\1'/" | ffmpeg -protocol_whitelist 'file,pipe' -f concat -i - -c copy output.mp3 ...
Cortez's user avatar
  • 11
1 vote
0 answers
139 views

How could I have VScode on Windows 10 with the default terminal changed to WSL2 Ubuntu-24.04 like a native linux distro?

I'm trying to have inside VScode for Windows 10 (Microsoft Windows [versão 10.0.19045.4474]) options to change the terminal from default to another one such WSL2 Ubuntu 24.04. I have installed ...
Marlon's user avatar
  • 379
0 votes
0 answers
38 views

Need Clang version at least 16

I am tried to compile the Apache Doris on macOS 13.3.1 follow by this document: https://doris.apache.org/docs/install/source-install/compilation-mac/. When I run the bash build.sh command, shows error ...
Dolphin's user avatar
  • 197
1 vote
0 answers
36 views

Why can’t I assign a requested address InspIRCd? “Reason: Cannot assign requested address”

I want to make an IRC server but when I run ./inspircd start it I get this. I turned off UFW and set up port forwarding, but nothing changes: Inspire Internet Relay Chat Server, compiled on Jun 8 ...
Matei Serban's user avatar
1 vote
1 answer
57 views

Bash prevent word splitting in array from command

I am using bash to get all of my directories with find . -maxdepth 1 -type d. I am then storing it in an array called selections. The issue is if a file has a space in it then i get some issues. When ...
Abbatrombone's user avatar
0 votes
0 answers
64 views

Permission denied: users/usr/.local/bin

I'm trying to install a program to download pdf files. This is the github link https://github.com/Lofter1/anyflip-downloader. I followed the istructions but I basically don't know exaclty what I'm ...
NoMilk's user avatar
  • 11
0 votes
0 answers
32 views

Redirecting standard output AND standard error in bash

I'm trying to write standard out and standard error to the same file. $ /usr/local/bin/aapt dump badging base.apk 1>sout.text 2>serror.text $ dog sout.text package: name='foo' versionCode='1' ...
confused's user avatar
2 votes
1 answer
74 views

Cygwin bash script file fails silently

I have a script file that uses rsync for backup, then compares the two directory trees using diff. diff seems to find all the differences correctly - it matches what WinMerge finds. But when there ...
Ronzone's user avatar
  • 21
0 votes
0 answers
31 views

Grep’s result coloring, and right-to-left scripts

I have a text file with a single line that contains the single Yiddish word azoy, in Hebrew script: אַזױ. Then I grep for occurrences of the oy character, ױ. (This is highly simplified of course, in ...
Ruud Harmsen's user avatar
-1 votes
1 answer
50 views

Hide files and folders with same name

I ran into an issue where I had to restart my computer during a large extraction process involving many zip files :(. All the zip files contain a folder that has the name of the zip file (minus .zip) ...
Brian Jester's user avatar
1 vote
1 answer
35 views

How to find the last N days from a log file [closed]

I have a log file like this: my test log line May 18 2024 13:30 my test log line May 19 2024 13:30 my test log line May 21 2024 13:30 my test log line May 22 2024 13:30 my test log line May 23 2024 13:...
NomeEoleSem's user avatar
0 votes
0 answers
37 views

Launching Windows apps from WSL2 with foreground process control

I'm using WSL2 on Windows 11 and I'm trying to achieve the following: I want to launch Windows applications from within WSL2 and have the Bash terminal maintain a handle to the new process. ...
dewijones92's user avatar
1 vote
0 answers
62 views

How to confirm ready state for an external USB disk before attempting other actions

[start of edit 1] Before I plug in my external USB backup drive, my computer is fully booted-up, and I am in my session as root. Because of its location, my USB cord is already plugged in, but I ...
Eric Marceau's user avatar
0 votes
1 answer
66 views

How to use grep with a pipe symbol from the command line

Maybe I'm missing something very simple, but I don't seem to be able to use grep from the command line (in bash) where the search argument contains a vertical bar |. For example, grep a|b results in ...
Mr Lister's user avatar
  • 276
1 vote
1 answer
60 views

Why I can't change the prompt in VSCode's terminal?

I am trying to change the prompt in my VSCode's terminal. My OS is MacOS Monterey 12.6. I use the zsh and I change the PS1 in .zprofile,such like this. Then I use echo to test.The others can work ...
Luxury's user avatar
  • 11
0 votes
2 answers
105 views

bash + how to insert date before line

lets say I want to pipe the date output in the beggining of some text for example echo "this line is test line" | date and expected output should be Wed May 22 14:55:10 UTC 2024 this line ...
King David's user avatar
1 vote
0 answers
97 views

how to install memcached via pecl?

I'm trying to install memcached and am having some difficulty. Here's what I tried: apt-get update apt-get install memcached libmemcached-dev libzip-dev pecl install memcached pecl install memcached ...
neubert's user avatar
  • 7,232
0 votes
1 answer
24 views

changing the directory a tarball decompresses to

When I do wget https://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz and then tar xvzf install-tl-unx.tar.gz the files get extracted (right now) to install-tl-20240521. On the CLI it's ...
neubert's user avatar
  • 7,232
0 votes
0 answers
41 views

Store output of command history

Is there some way to record not only the commands that I type in my terminal, but also their ouput? Is there maybe something that I can add to my .bashrc that could act similar to passing all commands ...
TheFibonacciEffect's user avatar
1 vote
1 answer
209 views

How to find matching yaml files based on content

I have a bunch of files that contain yaml. Some files are yaml-only, some have yaml front-matter. I would like to be able to query the list of files to return a list that match certain criteria. In ...
user2567544's user avatar

15 30 50 per page
1
2 3 4 5
236