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

learn more… | top users | synonyms

0
votes
1answer
21 views

Can we install a package through a shell script? [duplicate]

I'm trying to write a shell script so that when I reinstall my Ubuntu again. I could just run script and retain all the packages. And I'm planning to pass password in form of argument. My question ...
0
votes
2answers
43 views

tail/head all line except X last/first Lines

for example i have this file : cat myfile 1 2 3 4 5 i want to print all lines except first 2 line . output should be like this : tail -n $(( $(wc -l myfile | awk '{print $1}') - 2 )) myfile 3 4 5 ...
1
vote
3answers
388 views

cygwin's chmod behaves as working, but it does not work

My Cygwin installation is behaving strangely: chmod does not work. [09:45 Administrator@DellIns14 ~] > ls -ls /usr/bin/chmod 64K -rwxr-xr-x 1 Administrator None 38K Feb 6 2012 /usr/bin/chmod ...
0
votes
3answers
4k views

bash No space left on device

On VPS when I press tab under my user I get: bash: cannot create temp file for here-document: No space left on device but it works fine under root, what's happening?
0
votes
1answer
89 views

Zip epub using 7zip and issue with exlude file

I've many epub as folders need to convert it to .epub compressed so i created bash script to that ..which are compress the epub folder to zip then rename it to .epub using 7-zip btw i was try to use ...
0
votes
2answers
25 views

why doesn't xterm work with my script?

my script : echo 123456 > /folder/folder/123.txt I ran the script with xterm: xterm -e my.sh & It doesn't work.
0
votes
1answer
62 views

Using windows Git Bash in MobaXterm

I have custom macros etc in my mobaxterm, but I have worked for a half a year on a remote linux machines, now I have my code on my local PC and I use git bash. Can I use it through MobaXterm?
0
votes
2answers
18 views

find -exec where filename is not the last parameter

I am trying to pass the files from find command to adb push like this: find . -name "test0[4-8]*.py" -exec adb push {} \; /storage/emulated/0/ I get an error find: paths must precede ...
0
votes
1answer
30 views

How to pipe binary stdout to a compressed tls connection?

Not so long ago, I could use : cat somefile.txt | openssl s_client -connect server:port -quiet -comp However, this command doesn’t work, even with-ign_eof: $ cat somefile.bmp | openssl s_client ...
2
votes
1answer
18 views

Execute SSH port forwarding along with the browser

I've successfully set up dynamic port forwarding over SSH in Pale Moon and added the alias as ssh-forward in .bashrc. Now I have to execute both ssh-forward and palemoon to access the Internet over ...
0
votes
2answers
41 views

From logs, extract specific line after a grep by line number

I have a file, debug.log, from which I want to extract all the lines that immediately precede a specified pattern. Example: 1 blabla 2 blabla 3 HERE THE IMPORTANT THING 4 HERE IT MATCHES MY PATTERN ...
1
vote
1answer
12 views

grab history command and args for different commands

I have the following exercise: 47 vim wilson.0321 wilson.0329 I need to grab the last command and args to create: vim wilson.0329 right now I can grab the last arg or entire command: ...
2
votes
2answers
375 views

Working shell command doesn't alias

I can run, svn status |grep -v .jasper$ |cut -d ' ' -f8 |sed '/.*\..*/!d' |xargs ls -altr --color=auto just fine. But when I go to add this as an alias (alias svtr="...") I get an error saying... ...
3
votes
4answers
8k views

When running `rm -rf`, is it possible to exclude certain subdirectories?

I routinely use bind mounts to aid in making space available in multiple locations without having to have multiple logical volumes / physical partitions / LUNs, etc. For example, I may have a 200G LV ...
0
votes
1answer
11 views

lost virtualenv display to the left of bash prompt

I added thy Holy prompt to display my current branch so I never push to master. We all use it and it works, but I am no-longer seeing what virtualenv I'm using at the moment, which is a hassle. Based ...
5
votes
4answers
5k views

“watch” the output of a command until a particular string is observed and then exit

I'm looking for a way to programatically watch the output of a command until a particular string is observed and then exit. This is very similar to this question, but instead of tailing a file, I ...
3
votes
1answer
46 views

How to pipe AWK command output to Python as first argument

I have a plain text file input.txt which looks like: D000001 D000001 44 1975 D000001 D000408 1 1983 D000001 D000641 1 1977 D000001 D000900 27 1975 I process this file using simple AWK line: awk ...
1
vote
1answer
145 views

Send keystrokes to two windows at once

What I want to do: Be able to enter keystrokes while one program is in focus, but also send the same keystrokes to a second program on the other screen. What I have tried: xvkbd - I've tried ...
31
votes
7answers
75k views

How can I use a bash like shell on windows

I use Linux and a Mac. I'll be teaching some command line stuff soon. What can I install on Windows to give me a terminal window most similar to a basic mac/linux bash shell. Would like to be able to ...
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 ...
1
vote
1answer
211 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 ...
0
votes
0answers
30 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 ...
1
vote
2answers
204 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 ...
7
votes
1answer
4k views

Equivalent of bash's `source` command in Powershell?

To run a bash script line-by-line (so as to preserve environment variables, for instance), one does the following: $ . myscript.sh Or: $ source myscript.sh I have a PowerShell script that - ...
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
32 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 ...
-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
21 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 ...
12
votes
6answers
15k views

Copy files in Linux, avoid the copy if files do exist in destination

I need to copy a /home/user folder from one hard disk to another one. It has 100,000 files and around 10G size. I use cp -r /origin /destination sometimes I get some errors due to broken ...
74
votes
4answers
82k views
0
votes
0answers
21 views

Launch agent to run a .sh when it is added to a folder

I am trying to create a launch agent that will monitor a folder for when a .sh file has been added to it and then run it. <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC ...
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
27 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 ...
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 ...
1
vote
1answer
128 views

How can I create Keychain entries via command line?

I am trying to use the command line to automatically add passwords to the keychain app for various file servers. I was able to use the man security to figure out most of it. It's creating the ...
0
votes
2answers
30 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
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: ...
0
votes
0answers
23 views

cygwin: git commit - vim Editor always in line 5 but not on file edit

I am using cygwin on windows and git from the shell. VIM is configured as my default commit message editor. When I am editing my commit message, ie $ git commit my cursor always resides to line 5 ...
0
votes
2answers
341 views

Bash on Ubuntu on Windows (10) - Unable to connect to Upstart

Running the Ubuntu 14.04.4 LTS release (Trusty) using the new windows beta release with "Bash on Ubuntu on Windows" support. I'm having issues running services requiring upstart. ie: [15:08 ...
0
votes
0answers
19 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
30 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
2answers
317 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: ...
1
vote
1answer
44 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
2answers
49 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
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?
26
votes
6answers
8k views

Substitution in text file **without** regular expressions

I need to substitute some text inside a text file with a replacement. Usually I would do something like sed -i 's/text/replacement/g' path/to/the/file The problem is that both text and replacement ...
0
votes
2answers
41 views

'hhighlighter' wrapper script saying command not found [closed]

I have gotten the wrapper script 'hhighlighter' from https://github.com/paoloantinori/hhighlighter which colors anything you want in stdout. I followed the instructions about installing ack-grep, ...
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 ...
2
votes
3answers
655 views

How can I limit the number of directories in my prompt?

On my Mac OS X 10.6, I have my prompt set to PS1='\[\033[01;32m\][\w\[\033[00m\]\[\033[01;34m\]$(__git_ps1 " (%s)")\033[01;32m\]]\[\033[00m\]\$ ' How can I limit the number of directories in my ...