All Questions
1,572
questions
0
votes
1
answer
34
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 ...
0
votes
1
answer
112
views
ls -ltr on the terminal lists the files but says "No such file or directory" in a shell script
I am new to Bash and am practicing some shell scripts. I wanted to write a script to list all the folders and their file count, if a root path is passed as a parameter value from the terminal. The ...
0
votes
0
answers
43
views
Connect to PEAP wifi network on mac with a shell script
I am making a shell script for my mac and part of it requires connecting to my school's wifi network.
I have tried both of the following commands and while the settings wifi tab says that the computer ...
1
vote
1
answer
328
views
Complete overview of Bash and Zsh startup files sourcing order
I was confused in what order my shells source which files. When researching this for myself, I came across several sources online and even read some parts of the manuals for both shells. But still, ...
0
votes
1
answer
230
views
How to disable MOTD from Debian 12?
I am looking to disable MOTD on my Debian 12 systems. I updated my sshd_config file to not display MOTD but it is still showing up. Is it possible it is coming from another module and how can I ...
0
votes
1
answer
33
views
sed does not consume rest of the line
I have one line of different words stored in a txt file
N/A 9.0 Yes Yes N/A N/A N/A N/A 8.8 Yes Yes N/A N/A N/A N/A 8.7 Yes Yes N/A N/A N/A N/A 9.2 Yes Yes Yes Yes Yes Yes 9.1 Yes Yes Yes Yes Yes Yes ...
0
votes
1
answer
129
views
Linux Bash Wait Command Not Working
I am trying to use and bash file .sh to start other bash files in seperate terminals.
I want them to run one after the other as I use them to copy large numbers of files to the same Hard Drive. ...
2
votes
2
answers
70
views
Avoiding accidental execution of python scripts as bash scripts
I like to run my python scripts directly in bash like so
$ ./script.py
But sometimes I forget the shebang line #!/usr/bin/env python3, and it has the potential to overwrite a file named np if the ...
0
votes
1
answer
76
views
Why do string variables in a bash script behave differently when echo'ed than they do when passed to an executable?
I have the following script:
#!/bin/bash
KID3=$(command -v kid3-cli)
ARG1="-c 'get'"
file="'1-01 - Johann Strauss - __Waldmeister___ Ouverture.flac'"
echo Command:
echo "$...
0
votes
0
answers
113
views
Can you write a script that contains both bash (or sh) and powershell (or cmd, bat) so the same file can be executed on Win and *nix?
I have a script that needs to run on Windows, Linux and MacOS.
I know Windows determines how to run a script by using the file extension, where *nix will use the #!.
I'm hoping there is enough syntax ...
0
votes
0
answers
82
views
How to launch another blank terminal in Kali Linux?
When I launch another terminal in Kali Linux with Cmd+Shift+T, I can see Shell No. 2 tab created.
However, it is just a copy of Shell No. 1 and all the commands I ran on Shell No. 1 are visible on ...
2
votes
1
answer
117
views
Execute self-extracting bash script (with binary data appended) w/o saving it first
I have a self-extracting bash script (binary data appended to the end) like this:
#!/bin/bash
export TMPDIR=$(mktemp -d)
ARCHIVE_START_LINE=$(...) # <omitted>
# extracting data archive into a ...
10
votes
4
answers
2k
views
Why does assigning a variable with command substitution, and then echoing that variable, always fail?
Why does the following not work in Bash?
# Ensure TEST is unset
export TEST=''
echo "Hello world!" > test.txt && TEST="$(cat test.txt)" echo "$TEST"
It always ...
0
votes
0
answers
201
views
how to use curl for single sign-on website or page
I've already written a shell script but it's not working. I'm getting an empty response whereas it should first return a token and also it should login then register the API.
That's the task which my ...
0
votes
1
answer
58
views
How to simply cleanup a filename?
OS: Kubuntu 22.04.4 LTS x86_64
to display above:
neofetch --stdout |grep 'OS:'
.
How to simply cleanup a filename, not file contents?
by removing from a filename:
\n newlines
\t tabs
non printable ...
0
votes
2
answers
46
views
An incorrect path is displayed in my custom command line prompt in bash
I would like to display the current and parent directories in my Linux command prompt. For example, if the current directory is /home/user/proj/src, I'd like the prompt to display proj/src.
I found ...
0
votes
1
answer
46
views
no-ignore-case in grep command
In man page of grep --no-ignore-case matching control has the following description:
Do not ignore case distinctions in patterns and input data. This is the default. This option is useful for ...
1
vote
1
answer
325
views
Default shell zsh but responding bin/bash
I have no idea what I did! I was installing maven and one of the guides had me do something and now I'm stuck in default zsh. I've tried changing my terminal preferences to be /bin/bash, as well as my ...
1
vote
0
answers
134
views
WSL run a non-login shell even with `--shell-type login`
Previously running wsl sourced .profile for me, as expected:
As of build 16188 when running bash.exe without arguments (or with the ~ argument) bash will be launched as a login shell. The same is ...
0
votes
0
answers
85
views
Run custom shell script through udev
I'm trying to make an udev rule that'll play sound upon connecting the charger. The rule seems to work fine except I can not get the shell script to run. This is my udev rule:
$cat 01-mru-battery-...
1
vote
1
answer
118
views
What does it mean to "run something in a shell profile"
I'm installing Homebrew and I get a message that says:
Next steps:
⁃ To add Homebrew to your PATH run brew shellenv in your shell profile (e.g. ~/.bash_profile or ~/.zprofile)"
What does it ...
2
votes
0
answers
56
views
Setting GitHub Actions Secrets on Docker container build/run command, but encountering a parsing issue
I'm in the early stages of building an automated pipeline. Still in the exploring phase. Right now, I'm struggling with setting the environment variables for the container I'm going to run my app.
The ...
0
votes
1
answer
141
views
How to make bash script output compatible with both terminal and file?
In bash, if I want to produce periodical status messages, I can replace the previous one by emitting a hotkey combination, e.g. as seen here, here or here. When a user executes the script directly, ...
0
votes
0
answers
138
views
Cannot activate Python virtual environment from within shell script (zsh)
I cannot activate a Python virtual environment from within a shell script (zsh).
I have tried the following:
#!/bin/zsh
conda create -n myenv python=3.10
conda activate myenv
It sends me the error ...
2
votes
0
answers
101
views
Program is not interactive in NuShell
Some background
Qemu has a wonderful feature, which allows you to connect its stdio streams to serial ports on the guest. This allows you to connect QEMU's stdio streams to a TTY shell on the guest ...
1
vote
1
answer
243
views
Why is this tmux option not persisting?
I would like to generate a bashrc configuration file each time I start a particular tmux session, and I want to use my user's default tmux configuration file ${XDG_CONFIG_HOME}/tmux/tmux.conf as well. ...
0
votes
0
answers
160
views
How to run sh script in lxterminal using double click on Raspbian
I've read so many threads regarding running a script using double click, but none of the ways describes my case.
My operating system is Raspbian Bookworm (Debian), the graphical shell is LXDE and the ...
2
votes
1
answer
2k
views
"set editing-mode vi" vs "set -o vi" What is the difference?
On multiple forums I have come across adding set -o vi to my .bashrc file. Today I saw the option of adding set editing-mode vi to .inputrc.
I googled and both appear to do the same thing. Are there ...
0
votes
0
answers
91
views
While invoking bash without options -c or -s the first argument is a filename, how to execute it sourced? [duplicate]
While invoking bash without options -c or -s the first argument is a filename (see manpage bash).
In such a case bash executes that file and exits.
I just need this feature, yet that file has to be ...
0
votes
1
answer
103
views
linux + why command output cant be filter or can saved in file
clockdiff is command that measure clock difference between hosts
here is example from my Linux machine.
clockdiff -o 162.23.2.2
.
host=server11 rtt=750(187)ms/0ms delta=0ms/0ms Tue Oct 24 11:01:42 ...
0
votes
1
answer
101
views
Difference between './file' and 'sh file'
On macOS, in the zsh terminal, I ran the following commands:
cd /tmp
mkdir newdir
cd newdir
touch file1
./file1
The last command returned
zsh: permission denied: ./file1
But running
sh file1
executed ...
0
votes
0
answers
2k
views
How to solve exec format error while running container in ECS?
Previously the question was related to https://stackoverflow.com/questions/77266768/yarn-command-not-found-after-successful-docker-build. It was fixed but my problem is related to using shell /bin/sh.
...
0
votes
1
answer
2k
views
Where to set env var for Debian12?
There are too many places can hold permanent env var settings in Linux, so that I can't finger out which one is the most correct/proper.
/etc/environments
/etc/bash.bashrc
/etc/profile
/etc/profile.d/...
1
vote
1
answer
614
views
How do I change the background color for folders in PowerShell when invoking the "ls" command from WSL Interop?
I've installed the WslInterop module and exposed several commands from WSL2.
I'm using Import-WslCommand "apt", "cat", "awk", "nano", "find", "...
0
votes
1
answer
281
views
How to nicely print time difference in bash?
In my bash script, I want to print the time that my set of commands took to execute.
I'm doing this:
#!/bin/bash
start=$(date +%s)
./my-long-command.sh
./another-longcommand.sh
echo "Completed, ...
0
votes
2
answers
9k
views
How do I fix "Sudo commands will not succeed by default" on chromeOS Crosh Shell
I have been trying to install SeaBios for Ubuntu, and all of them say I need to use
Crosh Shell, every time I try to use it though it says "Sudo commands won't succeed by default" how can I ...
0
votes
1
answer
73
views
zsh on MacOS catalina 10.15.17
I'm having a little trouble putting this all together...
I want to make a simple shell script to organize and sort around 60 GB worth of music and movie files that are spread out over 3 or for 4 ...
1
vote
1
answer
227
views
CentOS 9 Stream SSH with PuTTy - multiline commands
I've been using CentOS versions 6, 7 and 8 for a long time. Finally, I started using CentOS 9 Stream version. It doesn't matter whether GNOME desktop version or server version (black screen), I ...
1
vote
1
answer
2k
views
Bash shell - shorter way to remove last characters from the file name
I can append a string to a filename without having to enter the repeating part of the command twice:
mv foo{,_bar}
And this renames my foo into foo_bar .
Is there a way to do the opposite - remove ...
0
votes
1
answer
204
views
Double-clicking .sh file on KDE fails to run the script
I have a simple .sh script on my Desktop that fixes a minor annoyance with my second display. If I open Konsole, and type ./script.sh, it runs perfectly. But if I double click that .sh file - it fails ...
1
vote
1
answer
460
views
Maintain a fixed-size-queue of nohup jobs
Suppose I would like to run multiple nohup jobs but at each time I would like to at most run 4 nohup jobs.
Is there a way to:
keep track of 4 nohup job status
once one of them finishes, it triggers ...
0
votes
1
answer
191
views
Linux RHEL 7 - Shell Script - Can execute command separately but cannot execute inside a script
I have a simple script use to install a package under cust privilege like this (command changed for security)
installScript.sh
#!/bin/bash
patch -i <package-name> << EOF
n
EOF
the purpose ...
0
votes
1
answer
2k
views
Linux RHEL 7 - Ansible - Execute command in shell is normal but got file not found/permission denied when run via script
I have an Ansible body as follow
- name: install
command: sh /installScript.sh
args:
chdir: /home/cust/
then I execute my playbook using this
ansible-playbook -i my_inventory....
0
votes
0
answers
791
views
Reference shell Script within a shell Script in YAML
Is there the right way to reference a shell script written within a script in a YAML file. For eg:
data:
ex1.sh: |
#!/bin/bash -x
. /shellscriptloc/ex2.sh
...
...
0
votes
0
answers
102
views
How do Linux terminal programs set up the environment for the shell program
I am writing a terminal emulator in Rust. The source is here. It forks itself and the child process (eventually) becomes the shell program which it reads output from and passes input to.
On macOS, ...
0
votes
1
answer
598
views
Running shell Script via Systemd.timer
So I've essentially run into the same problem as in my other question: Running shell Script via Crontab
I will now run my shell script with systemd.timer but it is not working so far.
Here is my ...
-1
votes
1
answer
904
views
I would Like to know what -sb and awk '{print $1}' role in this command
subdirectory_size=$(du -sb "$entry" | awk '{print $1}').
I would Like to know what -sb and awk '{print $1}' role in this command.
1
vote
2
answers
1k
views
Running shell Script via Crontab
So I've tried to run a shell script via crontab.
My Crontabs look like this:
00 20 * * * $HOME/Bilder/Hintergründe/.background_skript/background_night.sh
and my background_day.sh looks like this:
`#!/...
0
votes
0
answers
96
views
How to automate mybb installation using ssh bash script
I have created this bash script to install mybb application automatically on Centos stream 8.
SSH Bash script
#!/bin/bash
# Define variables for MyBB installation
DB_NAME=mybb_db
DB_USER=mybb_user
...
0
votes
1
answer
149
views
ProxyJump not running ForceCommand defined in sshd_config
On a bastion host, I have a shell_session_recording.sh script which uses the script command to record ssh session on bastion host and all interactive sessions ie all remote session after connecting to ...