Skip to main content

Questions tagged [bash]

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

Filter by
Sorted by
Tagged with
0 votes
1 answer
25 views

How to redirect the standard output to file without buffering?

I have a Python script test.py, which writes 100 lines, one per second: from time import sleep for i in range(100): print(f'line {i}') sleep(1) I would like to redirect its output to log.txt ...
Paul Jurczak's user avatar
0 votes
0 answers
23 views

How to use abbreviations in bash prompt [duplicate]

Can abbreviations (like the ones in fish or vim) be used/implemented/configured in bash? By abbreviations i mean something similar to alias but it's exanpded directly in the prompt so that I can ...
Moberg's user avatar
  • 67
1 vote
1 answer
29 views

Advanced argument escaping with find + xargs and nested commands

I know when you run into problems with piping the output of e.g. find .. to xargs due to 'strange' filenames, it can help to use a specific delimiter (e.g. \0) to actually pass full filenames (e.g. ...
frans's user avatar
  • 1,139
0 votes
0 answers
39 views

bash: "no such file or directory" for executable in PATH

In my process of installing java (as part of weblogic) with ansible I get this issue. I have seen that before from time to time, but cannot recall the solution. I have a new linux user "weblogic&...
groovehunter's user avatar
0 votes
1 answer
49 views

Why does Bash alias named “l” fail but works if the alias name is changed to “lf?”

When I put this line in my .bash_aliases: l() { pwd; ls -aoghs --author --color=always "$@"; echo `pwd` "$@"; } I get this error: bash: /root/.bash_aliases: line 4: syntax error ...
mark-hahn's user avatar
  • 101
5 votes
3 answers
291 views

Delete directories containing only .directory files

I have done a lot of cleanup by removing files in a directory tree. I would now like to delete the empty directories as there are now a lot of 'almost empty' directories: they contain only a hidden ....
dargaud's user avatar
  • 331
1 vote
0 answers
30 views

Store bash glob pattern in a variable

I can use syntax as below to list 6 files named a1b.md, a2b.md, a3b.md, x1y.md, x2y.md, x3y.md in a directory: ls a{1,2,3}b.md x{1,2,3}y.md I'd like to use something like this in a bash script; with ...
user74094's user avatar
  • 343
1 vote
1 answer
38 views

How to create a bash one-liner activating Python virtualenv?

I need to have a one-liner, which activates a Python environment and runs a Python script. None of my attempts worked: bash --rcfile /opt/venv/bin/activate -ci "echo $VIRTUAL_ENV" bash -c &...
Anton K's user avatar
  • 141
1 vote
1 answer
82 views

Exit code of a bash script when one of the steps fails?

So I have to run a basic shell script that is not much more than: #!/bin/bash call01 call02 ... call_N If one of the calls fails (gets killed by the OS because it runs out of memory), what does it ...
Yuri Makassiouk's user avatar
1 vote
0 answers
36 views

Move files recursively until specific name is reached?

I have a very large amount of files on a desktop that I'm trying to transfer to my laptop. I set up a Sambashare directory on my desktop, mounted it on my laptop, and started copying them. However, ...
Dragin's user avatar
  • 11
1 vote
1 answer
99 views

How to redirect output to both a file and stdout?

I have found multiple answers on the internet for variations on what I am after. None provide the exact solution. Specifically, I have a function func, which internally runs a make process. I have no ...
BrownianBridge's user avatar
0 votes
1 answer
29 views

iTerm 3.5 & Bash 5.2 prompt "shifting" where cursor shifts to right and is partially invisible [duplicate]

An odd issue I'm seeing with iTerm 3.5.10 and a Raspberry Pi 5 running Debian Bookworm 64-bit. I'm ssh'd in using iTerm and if I have a relatively long command in my command history, hitting the up-...
Barbituate's user avatar
1 vote
1 answer
29 views

Starting multiple iperf server instances with gnome-terminal

I want to use a script in Linux to start multiple instances of iperf3 as server like this: gnome-terminal -e --bash -c "iperf3 -s -B 10.10.1.1 -p 5021" gnome-terminal -e --bash -c "...
Donmanolito's user avatar
-1 votes
0 answers
42 views

Locking out user from sudo commands without rebooting [duplicate]

A more in depth explaination would be found here. The use case of what I'm trying to do is: You login to your desktop Linux computer. You start a script and as input you give to it a time in the ...
abolish_SO's user avatar
0 votes
1 answer
71 views

How to manually close ssh ports / port bindings?

I work on a mac 15.1 system and open a connection to a jumpserver for having the option to connect to several other servers. Usually the script works like a charm, but sometimes it gets stuck and ...
Calamity Jane's user avatar
0 votes
3 answers
76 views

Display relative date with `date` in human-readable format

I have date that I know will always be in future by at least one second. Then I calculate difference between date now and target date in seconds. But I can't figure out how to display second ...
sloppy's user avatar
  • 123
1 vote
0 answers
33 views

Must ssh-add two times when over SSH

I am on an Ubuntu machine. When I login normally from my desktop, my SSH credentials are added automatically and everything works correctly. However, when I instead work remotely via SSH, initially at ...
Svalorzen's user avatar
  • 133
0 votes
0 answers
19 views

How to get Variable from bash script to ocs_prerun Clonezilla options?

I don't see much in the way of Clonezilla questions, and have spent hours googling - nothing seems to answer my question - several SourceForge articles come close, but then the "answer" is ...
k1dfr0std's user avatar
  • 129
0 votes
1 answer
28 views

How to exit timed out SSH session without exiting earlier jumps?

I am aware I can type exit, logout, or hit Ctrl-D to logout normally. None of this works when the server is timed out, but thankfully I can do Enter-~-. to exit the session. However, this takes me all ...
Mario's user avatar
  • 1
2 votes
1 answer
96 views

Bash Script Fails to Find and Update Specific Line with `grep` and `sed`

I'm writing a simple script to add Wayland support options to specific application files. The script uses grep to check for a line, and sed to add options to it if the options are missing. However, I'...
NoKnowledge's user avatar
1 vote
1 answer
46 views

Where is the path of slurmd binary in a HPC system?

I want to find the path of slurmd binary in a HPC system. I used which slurmd but there was an error: /usr/bin/which: no slurmd in (/opt/xcat/bin:/opt/xcat/sbin:/opt/xcat/share/xcat/tools:/opt/ohpc/...
Martin's user avatar
  • 11
1 vote
0 answers
64 views

Cannot use arrow keys with BASH / Konsole / sqlite

I'm having a problem with Bash / Konsole / sqlite. When I enter sqlite and hit the up arrow key I get sqlite> ^[[A If I su into another user from the same Konsole session all is OK. I've looked at ...
Kevin Gilbert's user avatar
1 vote
1 answer
31 views

“multidimensional expansion” with brace expansion in Bash?

I think my use case is best illustrated with a concrete example, say with imagemagick: magick \( source_file_A1.jpg source_file_A2.jpg +append \) \ \( source_file_B1.jpg source_file_B2.jpg +append \) \...
Zorf's user avatar
  • 361
0 votes
0 answers
88 views

expect script inside bash doing remote ssh /etc/sudoers replacement

I am having issues with the below script. I am trying to replace a line in /etc/sudoers file but need to do it using sudo and either input my password or as in example here, put it in a variable. #!/...
john's user avatar
  • 1
1 vote
1 answer
39 views

Run bash scripts on KDE Plasma sleep and wakeup events of Power Management as a particular user?

KDE Plasma 5.27.11 on Debian 12 amd64 I need to send some very short signals over USB on workstation's power management sleep and wake up events(not login and log out, they work fine). I have prepared ...
tohaz's user avatar
  • 11
2 votes
1 answer
144 views

How to set a global variable from a bash function when its output is piped to another command

Let us define this very small bash function: function testit() { a=4 echo "Hello world" } if I run the function, then variable a will take the value 4 (which is the expected outcome): ...
jicarretero's user avatar
0 votes
1 answer
33 views

chroot to /mnt fails, when it shouldn't

I'm currently attempting to install GRUB on a disk image, for testing in QEMU. To generate the GRUB configuration file, you need to chroot into /mnt (as per this previous answer) and then run grub-...
Binary198's user avatar
  • 103
0 votes
1 answer
221 views

bash: java: command not found

My Linux distro is Debian 12.7.0, 64bit, English. I modified the guide titled How to install Java JDK 21 or OpenJDK 21 on Debian 12 so that I could "install"/use the latest production-ready ...
Renesah's user avatar
  • 23
0 votes
1 answer
30 views

bash and find: how to modify a path name from the lowest level up

I run the following command to recursively rid folders of characters that pose problems with certain apps, scripts, or on NFS/SMB, i.e., change ' to ’, ? to ? (chinese char), : to : (chinese char), ...
lucasart's user avatar
  • 151
0 votes
0 answers
57 views

ffmpeg overlay rounded corner webcam video on main video

I am trying to overlay a webcam video on top of the main video and have the webcam video rounded corners and place it at the bottom left corner of the main video. I want the webcam video to scale down ...
Zaid's user avatar
  • 1
1 vote
1 answer
102 views

Issue with Activating Virtual Environment in Shell Script on Raspberry Pi via Remote-SSH

I am connected to my Raspberry Pi 4B via Remote-SSH using Visual Studio Code on Windows 10. I wrote a shell script venv.sh remotely from my Windows machine: #!/bin/bash # Activate the virtual ...
Marco Moldenhauer's user avatar
0 votes
2 answers
52 views

What happens if I run this `set` command intended for Windows cmd prompt inside Bash in Linux?

What happens if I run this set command intended for Windows cmd prompt inside Bash in Linux? set "PATH=C:\Program Files\Git\bin;%USERPROFILE%\AppData\Local\Programs\Git\bin;%PATH%" echo %...
Gabriel Staples's user avatar
-2 votes
2 answers
59 views

i am not able to print sum of two columns from a live stream of data using awk

so i am trying to monitor how much bandwidth get used by transmission while torrenting. I searched and find an utility nethogs.if i run sudo netogs -t | grep transmission-gtk i get transmission-gtk/...
Sartaj Ansari's user avatar
0 votes
1 answer
144 views

Unzip to stdout with filenames and file delims

I have a tar which contains many zip files, each of which contains xml files. I would like to untar, unzip, and then do some stuff with the plaintext in the xml files. This entire program is being ...
ghosts_in_the_code's user avatar
0 votes
0 answers
73 views

How can I automatically remove all of a single audio track from an MKV and then verify that the audio track has been removed?

This is a bit of a multi-part question, so please bear with me. My NAS is filling up with TV shows, so for the purposes of saving space, I'm trying to remove all dubbed audio tracks from my multi-...
Tsumuri's user avatar
1 vote
2 answers
106 views

How to write to last 4 bytes of disk via CLI? Like using dd, optional

Warning, these commands (scripts) delete (change) data on your disk. Be sure to back up any important data on disks/drives before proceeding. You are responsible for lost data. You can use blkid lsblk ...
joseph22's user avatar
  • 499
0 votes
1 answer
26 views

bash completion, can one set a default word for first tab on a new terminal line

I have a container that the shell therein runs bash. It has bash completion installed and it works fine. This container has many custom cli commands but they all must be prefaced with nextcloud. ...
DKebler's user avatar
  • 268
1 vote
0 answers
78 views

How can I cap video length to just slightly below 60 seconds without re-encoding with FFmpeg?

I'm currently making a script to cap my videos at just slightly below 60 seconds. So if I have a video clip that is exactly 60 seconds long, I trim it by exactly 1 frame so it is slightly below 60 ...
Harry McKenzie's user avatar
0 votes
0 answers
45 views

bash tab completion doesn't work with source

When there's executables in my ~/bin folder, I can usually type part of it, for example "my_", and then hit tab so it auto completes to become "my_executable". However, when ...
Lost Crotchet's user avatar
0 votes
0 answers
29 views

miniset instalation error i: invoke-rc.d: initscript openvswitch-switch, action "start" failed

Overview I'm using Ubuntu 22.04 in WSL2 and I need to install mininet program: sudo apt install mininet And the follow problem occurs: pedro@DESKTOP-HNMS5UI:/mnt/c/Users/PedroFraga$ sudo apt install ...
Pedro's user avatar
  • 1
0 votes
1 answer
27 views

Finding nested `vendor` folder

I'm searching for a specific nested folder. This nested folder is in the form of **/**/vendor/**/**/vendor I would like to find and delete this 2nd vendor Any ideas?
bilogic's user avatar
  • 229
0 votes
1 answer
116 views

Speed up reading a large number of files (random read)

I'm trying to run a bash script on all the xml files inside a folder. After some effort I found the likely bottleneck is reading the files, given the filenames. My script is likely running fast enough ...
ghosts_in_the_code's user avatar
0 votes
1 answer
52 views

What is the meaning of "%CPU" when using GNU `time` command

I doubt my understanding of the output from running the GNU time command is correct. I am now wondering what the CPU percentage actually indicates. On macOS I have installed the GNU time utility gtime ...
John's user avatar
  • 446
0 votes
1 answer
91 views

How to spawn an Alacritty terminal from another Alacritty terminal that was spawn by Waybar

I'm using a Waybar module in an Arch Linux Hyprland setup, where my .config/waybar/modules.json is set as follows: "custom/clusterteleport": { "format": " Cluster ...
Dyin's user avatar
  • 158
-1 votes
1 answer
120 views

How to open an HTML file with Visual Studio Code inside of a Docker container?

I'm in Visual Studio Code's terminal inside a Docker container. How do open an HTML file in Visual Studio Code from the Bash terminal inside a Docker container?
Christopher's user avatar
0 votes
1 answer
983 views

Sudo apt update issue in Parrot OS 5.2

When I do sudo apt-get update in Parrot OS 5.2 I am getting this error. I also change the /etc/apt/sources.list but still getting the same issue. My source list is: deb https://deb.parrot.sh/parrot ...
usernotavalible's user avatar
1 vote
0 answers
29 views

find -type f -iregex '\.\/INPUT.*\.(mp4|avi)$' returns nothing, why? [duplicate]

I am on: GNU bash, version 5.2.26(1)-release (x86_64-pc-linux-gnu) I'm trying to get a list of all my video files with the extension .mp4 and .avi, my understanding with regular expression and follow ...
phenivol's user avatar
2 votes
2 answers
159 views

Can I find from which directory a command was executed?

A command find . -type f was issued on one of our servers by one of our users and its currently running when viewed in ps aux. How can I know from which directory was this command issued. Does that ...
rooni's user avatar
  • 153
7 votes
2 answers
892 views

How can I make second argument path relative to the first on a command? [duplicate]

For example, let’s say that you want to copy a file like this: cp path/to/the/file.txt path/to/the/file.copy It’s very frustrating to write the path twice so is there something like this with a ...
RoadRoller01's user avatar
2 votes
2 answers
178 views

How can I open a new Safari window with bash?

I'm working on a project that will let me open and close different pre-saved combinations of urls in different browsing windows. Since osascript/osascript/AppleScript or whatever they're calling it ...
sobbingDev's user avatar

1
2 3 4 5
238