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

learn more… | top users | synonyms

0
votes
0answers
22 views

How to expand a loop iterating over an array dynamically in BASH?

I need to iterate on an array and expand the array while iterating. How do I do it in BASH? For example: req="a b c d" read -a MODULES <<<$req for MODULE_NAME in "${MODULES[@]}"; do ...
-3
votes
1answer
44 views

What is the use of Bash in the next update for Windows 10? [closed]

In the Build conference this last month, Microsoft said that Bash was going to be introduced in to the anniversary version of Windows 10 in July. And I thought to my self, would this be an advantage ...
1
vote
0answers
20 views

tmux: get names of panes, each current directory and history

my tmux session is a bit broken, by which I mean that tmux ls returns an error like error connecting to /private/var/folders/d0/xbg08_x12lddw3dkht5w462c0000gn/T/tmux-501/default (No such file or ...
1
vote
1answer
23 views

How to pass array to bash shell script?

How do I pass an array as a variable from a first bash shell script to a second script. first.sh #!/bin/bash AR=('foo' 'bar' 'baz' 'bat') sh second.sh "$AR" # foo sh second.sh "${AR[@]}" # foo ...
0
votes
1answer
15 views

Nano does not resize to window size in bash on OS X

Any ideas on how I can fix this? I am not sure what to google for =[
1
vote
1answer
18 views

Accessing array index variable from bash shell script loop

I want to access the array index variable while looping thru an array in my bash shell script. myscript.sh #!/bin/bash AR=('foo' 'bar' 'baz' 'bat') for i in ${AR[*]}; do echo $i done The result ...
0
votes
2answers
29 views

How To Execute /bin Functions From The Python Terminal?

I'm actually running a python interpreter through a Linux bash terminal, and I'd like to be able to execute some of the bash commands in /bin through the python interpreter. How might I do this?
0
votes
1answer
28 views

Run script without typing sh on Android

I wanna run my script which is located in system/bin and permissions is 755. With sh myscript there is no problem but myscipt or ./myscript doesn't work even if the pwd output is /system/bin. On ...
0
votes
0answers
18 views

Bash in Conemu is overlapping lines

When I start nano/vi or a program that normally clears the screen then I can still see the command line. That means that the terminal is not cleared. If I scroll with the arrow keys the lines ...
0
votes
1answer
29 views

Copy Multiple Files w/ Same Extension but Add Date

I want to create a single command that will backup all my *.db files in a directory but I want to append the current date. a.db -> a_2016-04-21.db b.db -> b_2016-04-21.db c.db -> c_2016-04-21.db I ...
0
votes
1answer
15 views

Screen does not read /etc/profile.d on startup

Whenever I start screen, my alias definitions in /etc/profile.d are missing within screen. How can I make screen read/source all files in /etc/profile.d/ on startup?
0
votes
2answers
47 views

Replace backslash(“\”) with forward slash(“/”) in a variable in bash

I want to replace backslash(\) with forward slash(/) in a variable in bash. I tried it like this, but it doesn't work: home_mf = ${home//(\)//(/)} For example, I would like \a\b\c -> /a/b/c
0
votes
1answer
30 views

Running a web server via script at startup

I've got a puma webserver running my dashing dashboard from a linux VM. Currently, the VM starts as soon as my PC starts, but I have to manually run the server. I usually do the following after ...
1
vote
0answers
20 views

Bash traps not executing on last cmd for scripts passed in with -c

Here's an example: $ (newline=$'\n'; bash -c "trap 'trap ERR; echo handler' ERR; set -e;${newline}/bin/false") The handler will execute if I do any of the following: remove the newline trap on ...
1
vote
1answer
43 views

CTRL+R in shell - if I go past the command I want, how do I get back to it?

I'm feverishly hitting CTRL+R to find some command I used awhile ago, when suddenly I get to it. By reflex, I continue hitting CTRL+R, passing it for something further back in the shell history. How ...
0
votes
1answer
18 views

Rename php.ini.default to the more recognizable and standardized php.ini

When I type command: mv /etc/php.ini.default /etc/php.ini I get: bash-3.2# mv /etc/php.ini.default /etc/php.ini mv: ...
0
votes
0answers
22 views

Display scp progress in zenity window

I would like to graphically display the scp transfer progress of several files from a remote server to the local machine. I thought using Zenity for example. Browsing the net I found the command pv ...
0
votes
2answers
312 views

How to run a bash script via absolute path?

I have a file: /Users/danylo.volokh/test/test_bash_script.sh Content is very simple: #!/usr/bin/env bash echo "-- print from script" I'm in folder "danylo.volokh" This command runs fine: ...
0
votes
1answer
18 views

place the MySQL libraries in the correct location

Run the following command to place the MySQL libraries in the correct location: cp /usr/local/mysql/lib/* /usr/local/lib/ and I get bash-3.2# cp /usr/local/mysql/lib/* /usr/local/lib/ cp: ...
2
votes
3answers
35 views

How do I search for substrings in Bash?

I want to find out and display the total amount of TTT substrings found in the first 2,000 lines in the file. I had been using grep until I tested it, and realized it does not identify substrings.
0
votes
2answers
24 views

Pass variable to another pane

I'm working with tmux and I'd like to pass some information from one pane to another. For example in first pane i've got the folder by pwd command and instead of copypast to another pane I want to ...
1
vote
0answers
25 views

way to automate git repositories cloning

I have to clone several repositories on the VM-s and then building software on them. I have pretty nice build script but there is one issue. Before build, several repos should be cloned, and after ...
0
votes
1answer
94 views

curl command not found on OSX El Cap

My understanding is that curl should be installed. I had tried using curl from the Unix command line and got the message it could not be found. I'm wondering If something I did in efforts to clean up ...
0
votes
3answers
33 views

how to pass output of grep to “lsof -p”

I want to know the path of currently running ./a.out There are several MPI process, but I only need one of the PID of several ./a.out. So I first use below code to grep it ps aux|grep -P ...
1
vote
1answer
75 views

How to get bash-style autocompletion in zsh, (for git command)

I switched to zsh and find it better than bash, but I have a problem with oh-my-zsh's (hereafter "OMZ") autocomplete feature. When I type git chec, OMZ completes that to git check; in bash it gets ...
0
votes
2answers
26 views

How can I eliminate double login?

When I login into my Mac OSX a bash shell is configured to automatially open and run a script. This script requires super user privs and asks for my password again. Is there a way to eliminate this. ...
2
votes
1answer
20 views

Bash Regex oddity when using =~ operator

Consider this code: s1="1,2,3,4"; \ s2="1,2,3"; \ sP='^(([1-9][0-9]{0,},){1,2}){1,2}$'; \ [[ "${s1}," =~ $sP ]] && echo "\$s1 matches"; \ [[ "${s2}," =~ $sP ]] && echo "\$s2 ...
1
vote
2answers
65 views

How to split a string with quotes (like command arguments) in bash?

I have a string like this: "aString that may haveSpaces IN IT" bar foo "bamboo" "bam boo" I want to be able to split it like this: aString that may haveSpaces IN IT bar foo bamboo bam boo ...
1
vote
3answers
92 views

Bash on Windows: mv command - cannot move to a subdirectory of itself

I'm trying to install Ruby from sources on the Windows Linux Subsystem. I've successfully built from source in my home directory: ~/ruby/ruby-2.3.0 and I'm trying to move it to /opt/rubies/. When I ...
0
votes
0answers
63 views

Bash on Ubuntu on Windows: Can't change (some) directory colors

On the new Bash on Ubuntu on Windows (10) app, I have tried to change the directory colors from blue to some thing more visible but haven't been able to change some file/directory colors for some ...
1
vote
1answer
30 views

Mac Pro - $PATH messed up and “command not found” errors

I was installing opencv Python on my Macbook pro el capitan and in setting up the path messed up my .bashrc or path etc. I tried several of the suggestions on the SO and SU, to no luck, now i am ...
0
votes
1answer
35 views

email me when external ip changes

I'm trying to write a bash script for my server. What this script does is runs curl to get the latest IP address of my box and then email me if it's different from the old IP address stored in a file. ...
0
votes
1answer
156 views

How to access Windows folders from Bash on Ubuntu on Windows

On the Bash on Ubuntu on Windows app, I only have root@localhost:~# ls -a .bash_history .bashrc .profile How do I access all of the Windows folders like Documents, Downloads, etc.?
-1
votes
1answer
84 views

Bash on Ubuntu on Windows: ls command returns nothing at root level

On the new Bash on Ubuntu on Windows app on Windows 10, I tried to run ls from the starting directory to see the subdirectories but nothing comes up. I don't really know the directory structure so I'm ...
1
vote
1answer
22 views

Access to line arguments in shell script

I wonder if there is possible to access full command line call in shell script. In my script I need to pass it further. I find that there are $@ and $* accessors, but it do not pass all the ...
0
votes
1answer
35 views

How to suppress output of bash command

I've found this way of checking whether a host is accessible on a given port, however I am only interested in the status code of the command, therefore I am trying something like this: ...
0
votes
1answer
21 views

Shell Save the array element values in the variables

I need to copy the files from one folder to another, here source and destination information are in the text file. File content: res.txt /var/lib/jenkins/jobs/Android\ Gradle\ test\ ...
-6
votes
1answer
33 views

converting shell script to bash script

can anyone help me by converting this shell script to bash script pl. my shell scrpit is as follows #!/bin/bash ...
0
votes
1answer
28 views

Bash script to find content of file in a directory and add value

I have a directory with a huge number of files. I want to write a bash script to - Enter that directory Find out which of them are Perl scripts (but none of them have a .pl extension) Add a line at ...
0
votes
0answers
15 views

How do I create a Docker container with a non-default IP address?

I created a docker container with this command: docker run -p x.x.x.x:80:8080 <imageName> bash where x.x.x.x was the IP address of the Docker server running CentOS version 7. I then tried to ...
1
vote
1answer
203 views

Force download Windows update to build 14316

I’d like to try the new Ubuntu Bash on Windows, I’m already on the insider preview program and every time that I do a “check for updates” I don’t get any new update. My current build is 10585.218 and ...
12
votes
1answer
1k views

How to remove/reset Windows Subsystem for Linux on Windows Insider Build 14316

I installed the Windows Subsystem for Linux on Windows 10 Insider Preview build 14316. Now I would like to remove it or, better, revert to its factory defaults i.e. as it was when just installed. I ...
0
votes
1answer
20 views

Shell how to use a command to every regular file in and below the Dir

So what I have to do is find all regular files within and below the directory. For each of these regular files, I have to egrep for pattern($ARG) and find out if the output of the file matches the ...
0
votes
0answers
28 views

Update Azure VM running Windows 10 Enterprise N to build 14267?

I have Windows 10 Enterprise N running in an Azure VM and I'd like to update it to a newer build so I can try out Bash for Windows. It's setup to receive Insider Preview builds and its set to the ...
0
votes
0answers
17 views

Set PDF File Metadata from the Mac BASH Command Line / Script

Is it possible to set a PDF File's Metadata (Author = "Fred Smith" and Title = "This is my Book") from the Mac BASH Command Line or Script?
0
votes
1answer
56 views

Why might I be getting “Permission denied” for a directory that seems to have correct permissions?

I'm a member of the group that owns the directory dir, but I can't seem to access it. I'm not sure why I could possibly not have permission. See below: $ groups various including dir $ cd dir -bash: ...
0
votes
0answers
20 views

Force graphical login of a newly created os x user from bash

I'm working on an OSX build script for our department, and I've discovered that, although I can create a new users, I'm not able to set many preferences for that account until the account it logged ...
1
vote
2answers
79 views

find and exec on only filename

I need to find all files older than X days and delete them locally and from my s3 bucket. The problem is the find command returns me the full path and filename too. I tried messing with basename and ...
1
vote
2answers
185 views

Windows 10 build 14316: Ctrl + v doesn't work on Bash on Ubuntu on Windows

On the new Windows 10 insider build 14316, I haven't been able to use Ctrl + V (shortcut for paste) on the new Bash on Ubunbu on Windows app. Has anybody else had this issue? Any solutions? I have ...
1
vote
1answer
22 views

Bash: Is it possible to declare each list item on a new line?

Example: You normally list values in a horizontal layout for var in 0 1 2 3 4 5 6 7 8 9 do echo $var done It would be nice for version control and readability purposes to enter each list item on ...