Questions tagged [bash]
Bash is a free shell for Unix-like operating systems from the GNU Project.
11,706
questions
16
votes
4
answers
18k
views
List file range with UNIX wildcards
Say for example I have the following files in my working directory:
mjk0001.fits, mjk0002.fits, ... numerically increasing all the way to mjk9999.fits.
Is there a way to use UNIX wildcards to list or ...
0
votes
1
answer
1k
views
Change ConEmu directory to working directory with Git bash
I'm currently using the following to open a Git bash instance:
-new_console:"%ProgramFiles%\Git\bin\sh.exe" --login -i
This starts a new tab in the home directory.
I'd like it to start the tab in ...
1
vote
0
answers
417
views
Check to see if server is up
Create dir logs (for outputted logs)
Create a script IsTheServerUp.bash
Write a script to check if the server is up
Log(echo) the outcome to the file
Use curl command to check the server
Use ...
3
votes
1
answer
425
views
lftp: bash equivalent of command substitution backticks or $()
Is it possible to use bash-like command substitution, like backticks `` or $() with lftp?
This is to e.g. cd into a directory given by a command:
lftp ..
cd `pwd`
0
votes
1
answer
122
views
script which starts another script as another user, how to remove su process?
I have a bash script on Fedora Linux, which I run as root user, which starts another script as less privileged user rpmbuild.
#!/bin/sh
# start as another user, fork
su rpmbuild -c ./long.sh &
# ...
0
votes
0
answers
361
views
Executing Source command in bash for MAC
How do I call the source command in a bash script for Mac
This is my current script
echo Launch virtualEnvironment
source ~/tensorflow/bin/activate
so basically the source command isn't executed at ...
0
votes
2
answers
72
views
Single line command for MOVE preserving the same folder structure
I've found many solutions for this problem already, but all them copying and after removing the files. I need a single command who move or copy and remove file by file.
I'm not too deep in command ...
0
votes
1
answer
856
views
Bash for windows 10 not opening a program [duplicate]
I'm trying to run chrome and get its pid from bash for win10.
When I run "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" I'm getting C:\Program Files (x86)\Google\Chrome\Application\...
2
votes
1
answer
1k
views
gpg2 --quick-addkey without password prompt
I am trying generate in bash sub keys for a keyring without any keyboard interaction.
I have tried several approach around what is mentioned here
https://unix.stackexchange.com/questions/60213/gpg-...
3
votes
1
answer
841
views
Hide gui dialog pop-ups from bash script
I am running a bash script which executes a command that pops-up an annoying GUI dialog (I execute it multiple times inside the script). This pop-up disrupts whatever I am doing in the UI while ...
3
votes
3
answers
3k
views
Move each file into its parent directory in linux
Question
Assuming I have
dir 1/dir 2/file 1
dir 3/dir 4/file 2
(spaces in directory and file names are intentional)
I want to end up with
dir 1/file 1
dir 3/file 2
Related but incomplete answers
...
1
vote
3
answers
893
views
looking for list of symlinks in Dropbox folder - find syntax not working
I am trying to move my Dropbox folder from an External Drive to a different External Drive. I was getting error messages that files couldn't be moved and according to Dropbox tech support it's ...
1
vote
0
answers
147
views
can bash be configured such that ctrl-W deletes words correctly?
Readline offers us two different functions to delete a word, neither appears to be configurable, and neither does the right thing. Is there some voodoo I can perform which will combine the behaviors ...
3
votes
1
answer
4k
views
What is the purpose of using `call` here?
in a cmd batch file, I found the following line
call sqlcmd -S .\SQLEXPRESS -d main_dev -i create.sql
What is the purpose of using call here?
I am reading https://ss64.com/nt/call.html, but can't ...
10
votes
2
answers
9k
views
How to get the URL of Dropbox file from command line?
I would like to know if I can get the URL of a file to share in my Dropbox folder from command line. I would avoid to open the web browser every time.
2
votes
2
answers
1k
views
Disowned jobs still stop on exit
I connect to a remote server, and run something like this:
cat /dev/zero > /dev/null & disown %-
Then I do logout, and reconnect, and ps shows no cat process running. Why?
3
votes
0
answers
3k
views
Can't execute binary program
I'm using a fairly cut down version of Linux, which doesn't have Bash. It does however, have Ash. I'm not sure what exactly the differences are, but it seemed like it might be relevant.
Normally I ...
-1
votes
2
answers
284
views
How does bash make a file executable?
I know that when I run the command
chmod +x filename
bash will make my file an executable. What exactly happens to the architecture of the file to change it to an executable? i.e. how does the ...
1
vote
1
answer
6k
views
unable to execute: Too many levels of symbolic links
By mistake, I executed these commands :
sudo ln -sf bash /bin/sh
sudo ln -sf bash /bin/bash
When I rebooted the Linux server in recovery mode I got this message:
init : Failed to spawn friendly-...
1
vote
0
answers
1k
views
Which is correct: OSX Activity Monitor Swap Space Used Zero or Bash TOP command Zero Free?
I have several similarly configured macs, osx/macos 10.12.3, used as Jenkins followers.
In checking out another issue, I noticed Jenkins' report of its hardware status, claims there are 0 bytes of ...
1
vote
1
answer
2k
views
How to use "rm -rf --no-preserve-root" in bash on Windows
After turning on Developer mode and installing the Windows Subsystem for Linux, how can I use the rm command in the bash shell running in Administrator mode?
Example:
rm -rf --no-preserve-root C:/...
1
vote
1
answer
394
views
Change GNOME terminal colours when running screen
I'm using GNOME Terminal on CentOS 5.
I have the terminal settings customized to use the colours I like. However when I run screen (or tmux) the colours for my terminal input lines are always ...
0
votes
2
answers
257
views
bash or vimscript, how terminate script but leaving apps it started still running
In either bash or vimscript, how can I run a script that starts an app (xv or display) and have the script terminate by returning focus to vim, but
leaving xv/display still running. My current effort ...
1
vote
2
answers
1k
views
Source by bashrc when I exit an 'ssh' session
I'm on OS X and am using iTerm2.
I've updated my Bash profile on several of my servers so that when I ssh into them I can tell at a glance from the tabs what boxes I'm on. When I exit from an ssh ...
47
votes
7
answers
71k
views
The command 'ls -d' is not displaying directories. Is there a way to get 'ls' to only display directories instead of files and directories?
Is there a way to get ls to only display directories instead of files and directories?
From the man page:
-d, --directory
list directory entries instead of contents, and do not derefer‐...
1
vote
0
answers
649
views
How can I normalize multiple audio using ffmpeg?
I have seen this code:
vol=$(ffmpeg -i "$file" -af "volumedetect" -f null /dev/null 2>&1 | grep mean_volume | awk -F': ' '{print $2}' | /cut -d' ' -f1)
echo "existing mean_volume.........$vol"...
10
votes
4
answers
9k
views
Disable Bash's programmable autocompletion (based on command)
Bash in my Fedora 16 seems to autocomplete arguments based on the command itself. So if I for example type
cd Tab
… it will only show directories.
There are however far too many commands where ...
1
vote
1
answer
2k
views
Incron Won't Execute a Script But Cron Will, Permission Denied
I have a simple script to run rclone. It executes properly from the root command line. It also executes properly when called by a regular cron job. Permissions of the script are set as root/root ...
1
vote
1
answer
3k
views
Setting alias to use Macvim in terminal instead of standard Vim
I want to use MacVim console app instead of a standard vim.
In order to accomplish that I try to set alias:
alias vim="/usr/local/Cellar/macvim/8.0-119_1/MacVim.app/Contents/MacOS/Vim"
But for some ...
4
votes
1
answer
3k
views
npm commands not working on WSL with zsh
I've recently started using WSL, I've installed zsh and done some config.
I am however unable to use npm commands in the WSL bash window. I can happily use npm in Git Bash Cygwin, Command Prompt, etc....
2
votes
1
answer
1k
views
cd Command in ConEmu and MinGW
I'm running MinGW bash in ConEmu and have set the HOME variable to my desired directory c/Users/<username> in the MinGW/msys/1.0/etc/profile file. The problem is that when I enter cd in ConEmu,...
2
votes
1
answer
883
views
What are the rsync equivalent command/s to mv /a/b /c/d?
What are the rsync equivalent command/s to mv /a/b/ /c/d/, i.e, to move a directory tree from one location to another, possibly on another file system?
That is, not just copy, but delete the files ...
12
votes
3
answers
4k
views
Bash on Snow Leopard doesn't obey terminal colours
With the new version of Snow Leopard, OS X upgraded the bash version to GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0).
Now, my .bashrc sets the following settings:
# Colors
export ...
0
votes
1
answer
646
views
Run a command in a terminal, then when complete leave the command in the terminal
I have a problem where I need to launch a command from a terminal, and leave the terminal open with the command I used once it is complete. The reason is that depending on certain circumstances I may ...
1
vote
2
answers
128
views
How do I get functions/aliases defined in a bash script that's downloaded from a server (and executed) to work?
I had a .bashrc that I moved to server so that I can download and execute it through wget:
wget -O - http://xxx.github.io/dotfiles/bashrc | bash
It does get executed but any functions and aliases ...
3
votes
1
answer
3k
views
How can I kill the parent shell script process without killing child process?
I write shell script that runs PHP process.
But it was not running in background. Can I kill the shell script without killing the PHP process which is running?
4
votes
1
answer
2k
views
Convert date from YYYYJJJ in OS X?
I have a bash script that takes a date string containing the day-of-year (Julian day) and converts it to another format. The %j format character isn't parsing the string as I'd expect per the docs (...
3
votes
2
answers
2k
views
How to kill bash fork bomb
Recently I unintentionally created and run a fork bomb in bash. It was a slow one, in comparison to other fork bombs, I had plenty of time to do something. But there were already several hundreds of ...
0
votes
2
answers
785
views
oldest to newest file in directory tree and delete each file interactively
In the step 1, I am trying 'find' the oldest file in directory tree, which I solved by following this question.
Now I want to use xargs to delete interactively from oldest to newest.
Since this ...
0
votes
2
answers
943
views
How to pass password in bash without prompting to ask to type in?
What I wanted to do is:
run a bash script from my local terminal, to run a jar file in an EC2 instance.
But in order to run the script, I'll have to first log in with .pem credentials, and then do su ...
0
votes
2
answers
1k
views
combine multiple ifs bash
how can I simplify the following code if statements? Thank you
function git_dirty {
text=$(git status)
changed_text="Changes to be committed"
changes_not_staged="Changes not staged for ...
0
votes
1
answer
732
views
Why is grep printing when there is no match?
$ ps ax | grep 6557
#=> 6582 s003 S+ 0:00.01 grep 6557
But checking quickly with activity monitor there is no process with a pid 6557. And everything online says grep should return 0 when ...
3
votes
2
answers
477
views
How to redirect ALL output from a command in Linux
I'm running Gentoo Linux. A program (equery) outputs a massive list of all the currently installed packages (equery list "*"). I want to find out which of them are unstable. Equery marks the unstable ...
5
votes
3
answers
10k
views
pipe command's output to dialog and allow to scroll up
I want to run an arbitrary command, for example
find / -name "a*"
I want to pipe its output to to dialog. --tailbox and --progressbox handle this well, except that if the output becomes too much, ...
0
votes
1
answer
1k
views
New bash on windows 10 cannot use gulp
I installed it yesterday, and I cannot find a way to bypass all the errors I get:
[nodemon] Internal watch failed: watch /home/user/myFolder/whatever EPERM
listen EACCES 0.0.0.0:80
These works on a ...
11
votes
1
answer
13k
views
Bash on Windows / Windows Subsytem for Linux (WSL) not installing correctly / hangs
I got the windows anniversary update and tried to install Bash. I ran bash from the command prompt (non-admin mode) and it got stuck while trying to extract the files. I closed the window and tried to ...
0
votes
0
answers
46
views
How to use case statement for os level versioning
I am trying to write a script which basically gets executed according to the os version..This is what i did till now..
#!/bin/bash
publicyum="yum.oracle.com"
osrelease0=`lsb_release -r | awk {'print $...
10
votes
3
answers
2k
views
What causes strange CPU usage output of htop in Bash on Windows
When I run htop in Bash on Windows I get the following output regarding CPU usage:
while the Windows Task Manager shows around 1% usage.
From here it's clear that htop's red regions are supposed to ...
1
vote
0
answers
140
views
bash in windows 10 (anniversary update) keeps adding characters to command line
I've managed to set myself up such that i can launch bash from my command window in windows 10. It's pretty cool! The only problem is that when I ssh into a remote linux box and run different ...
83
votes
3
answers
6k
views
How to unalias a minus?
My morning coffee hadn't reached my brain yet when I forgot the quotes in:
alias grep="grep --color=always"
so instead I typed:
alias grep=grep --color=always
leaving me with:
--color=always
grep=...