Questions tagged [bash]
Bash is a free shell for Unix-like operating systems from the GNU Project.
11,707
questions
1
vote
1
answer
764
views
How to fetch Rundeck Job output through terminal?
The purpose of my code is to download the output log generated by a specific rundeck job number, that is hosted on my local rundeck server.
So I tried using
curl -o output.txt -0 https://xx.xxx.xx....
0
votes
1
answer
75
views
The -r flag for directories seems to be useless now [closed]
cp, scp, rm and other command needs to the -r flag to perform an action on a directory, compared to just a file.
can't copy a directory because WHOOPS you forgot the -r flag
I don't feel this is ...
1
vote
0
answers
136
views
Mac Terminal or iTerm: Copy the current command (not including prompt)?
I am using Terminal or iTerm (iTerm2). Let's say I've typed in a command but haven't hit enter yet. Or maybe I used the up arrow to navigate through my command history. How do I copy the current ...
3
votes
1
answer
8k
views
Amazon Linux 2 su command not found
even though I am already working with Linux for years somehow I can't figure out the following issue.
I am using the following docker image:
amazoncorretto:11.0.6
When going into that image
docker ...
0
votes
1
answer
49
views
Difference in output in apparently similar bash scripts
I have a folder containing two files scrap.sh and data.txt. In the bash script I have the following script
x="$(ls -l)"
echo $x
The output of running this script is all on one line
total 4 -rw-rw-r-...
0
votes
0
answers
140
views
Issue with an ACPID bash script
My last post didn't get a correct answer, so I decided to refine/narrow my question in another post. If you want to refer to the other question, go:
Run script when power button pressed
So I am ...
0
votes
1
answer
1k
views
How to check if there is a file in remote SFTP server before I copy and delete?
I am using standard SFTP in Linux and I want to check if there is a file in the file folder before I execute my script.
My script would only get the all the .TXT files in the file folder then would ...
1
vote
0
answers
383
views
Execute a command on screen termination
I have been using screen for a while, but the process I am running seems to terminate at times, closing the screen out. So I have to reopen the screen again.
I was wondering if it was possible to ...
4
votes
2
answers
6k
views
Run script when power button pressed
When I push the power button, I want to run a script. For the sake of this scenario, say file.sh. So when I push the power button, I want to run file.sh and only file.sh.
Most of the solutions I found ...
1
vote
1
answer
1k
views
read answer not working on ssh bash -s script
I have some commands to prompt for yes or no answer in my script, but the read answer command (interactive mode) not working, while running the script using ssh bash -s script.
ssh user@hostname ...
1
vote
1
answer
402
views
How to programmatically get the list of directories that brew installs to?
I am writing a script that automates setting up my mac dev environment. I want to place the directories that brew installs first on my path, so that the default system commands are overridden by brew ...
2
votes
1
answer
36
views
What does :~ evaluate to in Bash?
What does :~ evaluate to in Bash? I've accidentally ran the command mv somefile.txt :~ while logged in as a root user. The PEM key I use to login as that user no longer works and when I attempt to ...
0
votes
1
answer
64
views
awk comparison on Ubuntu
I'm trying to write a script that check the disk usage of remote clients. There is a filter in script for meaningful output:
...
ssh server "sudo df -Ph 2>/dev/null \
| tail -n +2 \
| grep -v ...
2
votes
1
answer
379
views
Why does `echo | xargs > >(cat)` hang on my Mac?
This is reproducible in zsh and bash.
Confusing me further, echo | ( xargs; : ) > >(cat) does not hang. This is also reproducible in zsh and bash.
If I use GNU's xargs as provided by brew ...
0
votes
1
answer
330
views
Why does an interactive command (git add -i) exit immediately?
I've used git add interactive before -- nice little ascii GUI.
Today when I ran git add -i, it prints all the expected dialog, and then exits immediately. (screenshot below, bash in gnome terminal.)
...
0
votes
1
answer
103
views
How can I add more username and passwords here?
The contents inside the bash file will be obfuscated
echo "Enter The Login Name:"
read username
echo "Enter The Password:"
read password
if [[ $username == "user" && $password == "password" ...
0
votes
2
answers
172
views
Kill an automatically delete file script
Kind of a newbie to bash, sorry.
I wanted to generate a script to enter all directories under current_directory with "bifn*0.2e" in the name and then automatically delete files every minute with "acc"...
1
vote
1
answer
414
views
Migrating aliases from bash to zsh
I recently moved from bash to zsh. Everything is great, I love it! Except some of my old aliases are getting confused. I have a long list of aliases like this that I've just migrated wholesale from ....
1
vote
1
answer
953
views
Replace a line containing special characters in all files recursively using SED MAC
I was trying to replace a line with another using SED on MAC OS X Terminal
I have a scenario where I need to replace a line in all files present in a directory with another line.
Both lines are ...
1
vote
0
answers
65
views
Cygwin: Is it safe to pipe from /dev/clipboard to clip?
I am using cygwin on windows.
Given a long list of strings in the clipboard:
mail
know
trial
posture
wind
census
shelf
concrete
moon
fee
If I want to "unwrap" them, is it safe to use such a command:...
1
vote
1
answer
255
views
Ubuntu 18.04 debconf shows prompt
I am trying to install MySQL 8.0 on Ubuntu 18.04 automatically using bash script.
I was setup all variables which debconf prompt asking, but prompt is appear anyway.
What's wrong in my script?
#!/bin/...
0
votes
1
answer
1k
views
get WM_CLASS of active window with non-ANSI letters in its title
trying to get WM_CLASS of active window to make AutoKey script for hotkey that works differently for different applications
here is one way to do it:
winname=`xdotool getactivewindow getwindowname`
...
1
vote
1
answer
748
views
Writing a systemd script that starts 2 applications in linux
OS: Raspbian
I'm failing to execute 2 applications at once with rc.local
I need to find a simple example for how to start an app with systemd
The problem is Im only finding specific examples for ...
4
votes
1
answer
3k
views
Is shebang necessary in git bash scripts on windows
Shebang is the first line of a bash script telling where the bash script is executed. In Windows git bash scripts, is it necessary? If not, why?
0
votes
1
answer
2k
views
Get Python Version with Bash Script
I have a script that gets the python version from clients. The command in bash is:
pythonVer=$(ssh $user@$ip "python --version")
But this command shows the python version on stdout (my ...
-1
votes
2
answers
72
views
Preserving quotation marks using bash history
You run a command like echo "hi world".
hi world
Then you run echo !! to try to display the command you just ran.
echo echo "hi world"
echo hi world
The first line outputs the command that will ...
1
vote
1
answer
288
views
How to use pipe into grep to exclude list of files under a second level directory?
I use ripgrep (rg) to list files under a directory.
But I want to list files under a second level directory excluding the list of files under one of the directories.
Basically if I have ./a/b/c
I ...
0
votes
3
answers
726
views
Why is it okay for my .bashrc or .zshrc to be writable by my normal user?
My user ~/.zshrc file has the following default privileges
-rw-r--r--
My understanding of user permissions is that any process spawned by my user will then have read/write permissions to this file.
...
0
votes
2
answers
223
views
How to remotely tell a Mac to sleep without using SSH?
I am needing assistance in getting a Mac to go to sleep without the usage of SSH. Almost any other method is acceptable.
Backstory: Product Salesman and Project Manger sold a thing without asking ...
1
vote
2
answers
714
views
why in linux size of directory remained same even after deletion of its files and subdirectories?
Why in linux size of directory remained same even after deletion of its files and subdirectories ?
I have created a directory vv1 and inside it created 500 files. ls -lrt was showing size vv1 as ...
2
votes
2
answers
2k
views
How can I reset all alias in powershell
I recently setted alias to an non command as I do not know how to use set alias. I am wondering how I can reset all alias without affecting the default alias that come with powershell.
I tried to ...
2
votes
0
answers
2k
views
Vim text messed up over ssh on Windows remote host regardless of terminal, works fine on Linux remote host
vim works fine on the first invocation on a remote Windows host, but further use leads to my terminal getting messed up. :redraw! and reset do not help:
Using the same local terminal, vim works fine ...
0
votes
1
answer
228
views
Irreversibly terminated terminal session
I was trying to update bash in my terminal and I have managed to accidentally log out and terminate bash. Now, whenever I open the terminal the following info is displayed:
Last login: Sat Jan 25 10:...
0
votes
1
answer
1k
views
How to start urxvt with tmux
I want to run tmux when I open urxvt terminal, I found somewhat functional solution;
[[ $TERM = "xterm" ]] && { tmux && exit 0; } *in .bashrc
But replacing "xterm" with "urxvt" or "...
-1
votes
1
answer
24
views
Modifying binary output before returning to the prompt mode
I have a binary which prints a question and then waits for a user answer.
I have no access to the source code of this binary, but I want to modify the screen output.
Example:
> ./commandx
Day 1
...
1
vote
2
answers
2k
views
infinite history in bash, when using multiple terminals(terminator) without losing commands and messed up order
I want infinite history, because I type a lot of commands I can forget at the spot and would like to have it stored somewhere as a reference. But by just setting HISTSIZE and HISTFILESIZE it does not ...
1
vote
1
answer
1k
views
ImageMagick: How to add multiline text superimposed over picture? Text is truncated
Code -
convert -size 2000x1000 xc:none -gravity center \
-stroke yellow -pointsize 50 -font Courier-BoldOblique -strokewidth 3 -annotate +100+100 caption:'Conflict is the gadfly of thought. It ...
0
votes
3
answers
408
views
Creating an alias that is an incomplete command
The documentation from tldp.org doesn't really specify when or how the bash interpreter replaces an aliased string. I'm looking for information on how to create an alias that is an incomplete command.
...
3
votes
2
answers
7k
views
How do I target and close a specific Terminal window in AppleScript?
Background
Given the below terminal script, I want to modify the osascript so that instead of targeting the front window I am targeting the specific window that is opened from the AppleScript.
...
0
votes
1
answer
2k
views
tail -n1 on latest non-empty line
I wanted to achieve something similar to this
grep -v '^$' <myfile-with-blank-lines-at-the-end> | tail -n 1
Basically, I have a file with a unique number, followed by a comma
and I want to ...
0
votes
1
answer
2k
views
Shell Script to Unzip/Extract zip files based on content code
I have multiple zip files for each day but the content of files differ based on the first code for each file. So, based on the code, I need to pick files for processing. If the code is 100 in the zip ...
3
votes
2
answers
3k
views
How to get the pid of a opened Terminal window in MacOS?
Background
I want to obtain the pid of a specific Terminal window.
ps -A | grep -w Terminal.app | grep -v grep | awk '{print $1}'
However, the above grabs the pid of the entire application and not ...
2
votes
1
answer
484
views
Clean up GNU parallel sem
I've run some commands using sem -j <number> <command>. Then I cancelled the whole script.
Now, even after rebooting the machine, I cannot use sem any more, even sem -j 2 "echo HELLO" ...
0
votes
1
answer
2k
views
How to close a Terminal window using bash and AppleScript without using SystemEvents?
Background
I am trying to create a script that when executed, opens a new Terminal.app window executes the desired commands and closes the window when complete.
One solution was to use SystemEvents ...
1
vote
0
answers
2k
views
Windows 10 - GIT issues with cloning/pulling/pushing
I've got an strange issue. Since I updated my GIT on my Windows 10 machine, I get the error below.
I use GIT for Windows with Bash.
If I run GIT Bash with administrator rights then everything works ...
0
votes
1
answer
105
views
Piping your current $PATH to VSCode as a shortcut
My knowledge on shell usage, regular expressions and system processes is rather small. I know I can pipe de result of one command to another.
Yet doing pwd | code or $PATH | code doesn't yield the ...
1
vote
1
answer
1k
views
Bash command after sshpass not executed
Why are commands after sshpass not executed?
Should I somehow signal that the ssh connection has been terminated?
#!/bin/bash
SCRIPT="cd /proj
./run_server &
...
3
votes
3
answers
2k
views
Sequential parallel with wait
I want to run a multi-parallel task in one bash file like the example code below,
for i in 1 2 3 4 5 6 7 8; do
setsid python /tmp/t.py ${i} 1>>/tmp/1.log 2>&1 &
done
wait # ...
2
votes
2
answers
1k
views
How to split and join parallel pipes?
I'd like to pipe the output of 1 command into multiple pipes and pipe outputs from multiple commands into 1 single command.
An example of split:
# Single output to multiple pipes
echo "This is a ...
1
vote
0
answers
45
views
I can't use the window manager of my choice, nor the display manager
I'm stuck with xfce and a text-only login screen. I've tried to run
startkde
instead of
startx
to see GUI and I got this
$DISPLAY is not set or cannot connect to the X server.
I tried to fix it ...