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

learn more… | top users | synonyms

17
votes
7answers
11k views

How to remove duplicated files in a directory?

I downloaded a lot of images in a directory. Downloader renamed files which already exist. I also renamed some of the files manually. a.jpg b.jpg b(2).jpg hello.jpg <-- manually renamed `b(3)....
4
votes
6answers
2k views

What is the simplest way to remove lines from one file matched with lines from another file?

What's the simplest way to remove lines from one file matched with lines from another file? For example, if I have the following files: file1.csv: u2@domain.com file2.csv: 1,u1@domain.com,...
3
votes
4answers
12k views

“command not found” when running a shell script. What did I break?

I'm on OSX Snow Leopard. Here's the full contents of grr.sh: #!/bin/sh echo wow When I try to run it from terminal: $ grr.sh -bash: grr.sh: command not found $ /bin/sh grr.sh wow $ sh grr.sh wow ...
2
votes
2answers
3k views

Changing the HOME for Cygwin

I'm trying to change the home directory for Cygwin on a computer at work. Our home directories mapped to a network share by default. This seems to cause some confusion for Cygwin, as it created a ...
0
votes
2answers
39 views

Is it possible to check for blips in internet using SSH tunnels?

So basically at work we're losing internet connectivity for just a few seconds at a time, which is enough to kill our SSH tunnels, kill our VoIP calls, etc. I have a cronjob set up with my own script ...
1
vote
3answers
271 views

WSL(ubuntu/windows) AppData\Local\Lxss doesn't actually sync back to ubuntu, ideas?

If you create a file in bash (touch /root/foo.txt) that appears in the hidden directories in AppData\Local\Lxss\ modifying it there does not change it in bash. Worse if you change it again in bash ...
0
votes
2answers
58 views

Importing variables in one shell script from another without executing the referred shell script

I have 2 shell scripts, file1.sh and file2.sh file1.sh #!/usr/bin/env bash export var1="/data/share" export var2='password' echo "Hello" file2.sh #!/usr/bin/env bash source file1.sh echo $var1 ...
4
votes
4answers
2k views

Can't rename a file the name of which starts with a hyphen

I'm trying to rename a file with a hyphen at the beginning of its name and both this: mv -example-file-name example-file-name and this: mv '-example-file-name' example-file-name result in: mv: ...
0
votes
1answer
896 views

How to run script before starting vpn connection?

I need to run a bash script BEFORE connecting to a vpn (which I do by clicking the network manager applet). I need this script because when connecting to the vpn the routes are incorrect. The script ...
2
votes
2answers
2k views

How to kill a continuous process started from rc.local?

I'm working on a Raspberry Pi with Raspbian (Debian-based) OS. For testing I added such a command in /etc/rc.local: python /home/pi/test.py It works fine starting this script. But the problem is ...
1
vote
0answers
20 views

Find windows program pid with its path

I want to kill a program with a windows bash script.I need to find the pid of a program with its path.we have three different directories with same program on a computer.We start all program all of ...
59
votes
4answers
97k views

Bash: Display each sub-directory size in a list format using 1 line command?

I want to get a list of the directories and their sizes in a list format like how you get when you do a ls -l. The thing is that is there a one line command that can do this? I see others have long ...
0
votes
0answers
8 views

Reverse search in PowerShell ISE wanted

In Bash, you can reverse search your history using Ctrl-R and start typing. Is there a similar feature in Windows PowerShell ISE?
0
votes
1answer
14 views

nohup on bash redhat is one processID different

I'm using capistrano to deploy a python service. I was trying to both start the service and also write a pidfile, so I can restart the service or stop the service later. The problem is the pidfile is ...
0
votes
1answer
16 views

Check MD5 of a file header hosted on a webserver

I am writing a bash script to periodically download a setup file using cURL. The problem is the following, the file is around 110 MB and always have the same filename. I can download the file, check ...
1
vote
1answer
28 views

Check if a script completed executing instead of exiting

I'm working with a script that I cannot modify, that does not use exit codes. (all exits are simply 'exit') Without modifying the script (or yelling at the idiots who wrote it), is there a way to ...
0
votes
2answers
12 views

How to terminate a cli app when stdout contains a certain string?

I've got a command line app that outputs lots of information to stdout. How can I terminate the program when stdout contains a certain string? e.g. something like: my_program | ...
1
vote
1answer
32 views

Disable autocomplete hints on iTerm2

I would like to disable the autocomplete history things that come up on the iTerm, as shown in the picture below: I would like to get rid of the blue hint that comes up when I start typing a ...
7
votes
4answers
18k views

How can I get Mac OS X's proxy information in a Bash script?

I have several network locations set up on my laptop: Work, Home, etc. The work one(s) all have a proxy server set up, while the others don't. This works fine for OSX applications -- Safari, Mail, ...
1
vote
0answers
42 views

Speedup zsh startup time

I'm on MacOS 10.11. When I open a new tab on Iterm2, it takes almost 2 second to have the prompt. So I guess I have something in .zshrc / .bash_profile / .bashrc that takes times to load. Here are ...
2
votes
1answer
191 views

Export bash function over SSH

I would like to export a bash function over ssh to use it in GNU parallel. That question seems to be answered here Exporting bash functions through ssh but I don't seem to be able to get it to work. ...
1
vote
0answers
13 views

Bash&TMUX - Continue after error

I want to write a bash script which opens new window in certain tmux session, runs another script in it and then closes. The problem is, if I launch two instances of the script, I want the script to ...
1
vote
1answer
59 views

Windows 10 linux bash shell ctrl+space doesn't set mark in Emacs

In Windows 10 I installed Subsystem for Linux Bash. But I have a problem with shortcut in Emacs Ctrl+space doesn't set mark point. What i tried and didn't help: I tried to uncheck "enable Ctrl key ...
6
votes
3answers
7k views

How to redirect to stdin of a running bash shell?

Theoreticly, if I know the pid of the bash shell which is running, I can run a cat whose stdout is redirected to the stdin of that shell. It seems to be as if I type something on that shell. ...
0
votes
1answer
51 views

How to extract specific data from the table?

Here is the table... Group Name Designation 2 (John) Front End Developer 12 (Jim) Back End Developer 8 (Jill) Full Stack Developer 21 (...
0
votes
3answers
10k views

Autostart programs/scripts in Debian 8 Jessie

I have a scipt (.sh) for screen rotation of my thinkpad on linux. I have now installed Debian 8 Jessie and the "Startup Applications" is no longer there, how can I make it to startup on boot? or user ...
0
votes
1answer
13 views

Create a select list of users in Bash on OS X

I am trying to create a copy script to quickly copy a user folder in OS X, while excluding all the junk (caches, old iPhone Backups, logs, etc.). As far as not copying those files/folders I am not ...
0
votes
0answers
29 views

How to use scroll wheel for command output history in a minimal install?

If someone ever booted up a GNOME desktop and accessed the terminal you would be quick to realize that the scroll wheel is able to move back and forth through command history. To me this is an ideal ...
1
vote
1answer
55 views

How to kill all child processes of a terminal, not a tty session?

At my workplace, we have a high-performance computing-cluster managed by SLURM. Some people's jobs spawn lots of processes with, as a federation, are one job. They also write the top-level controller ...
9
votes
3answers
3k views

How to change the default shell in Cygwin?

I am trying to change my default shell from bash to zsh in cygwin. The normal unix command chsh isn't available on cygwin The etc/passwd file it seems isn't used anymore in existing versions of ...
48
votes
3answers
12k views

how to expand aliases inline in bash?

Is there a way to expand aliases inline in bash? $bash>alias ll='ls -l ' $bash>ll<tab> $bash>ls -l
2
votes
2answers
622 views

Crossfading Video AND Audio with ffmpeg

This Super User answer crossfade between 2 videos using ffmpeg has got me so far, but now that I have tried many solutions and seen every SO link out there, it's time to ask you all for help. I am ...
1
vote
2answers
4k views

`adduser [options] user group` fails ubuntu 11.04

I'm want to use adduser However it doesn't seem to work if I provide the second argument for the user's group root@a:~# adduser rick staff adduser: The user `rick' does not exist. The group exists ...
1
vote
2answers
27 views

What is the equivalent of Linux's (bashe's actually) “&>” in Windows?

How can I redirect (to one file) stdin and stderr of the program? I look for something like &> in bash for Windows.
0
votes
1answer
15 views

Reset Cache using bash

I'm trying to automate a .sh file to run every time before Chrome opens, here's what I want to do. rm -rf /home/pi/.config/chromium tar -cvf reseterfiles.tgz /home/pi/.config/ The zipped ...
4
votes
4answers
3k views

How do I `cd` and then* `ls` automatically in linux?

I have found myself keep doing cd some_dir quickly followed by ls for quite some time now, and have been trying to write a bash alias to let me do this, such as: alas cd="cd $@; ls"; Problem with ...
0
votes
2answers
43 views

How to add .bash_profile in Windows to run Matlab-based IPython notebooks

I'm looking at this tutorial to run matlab code in IPython notebook: http://anneurai.net/2015/11/12/matlab-based-ipython-notebooks/. but I am stuck at step3: I edited the .bash_profile file located ...
1
vote
1answer
19 views

How to 'set -x' for scripts other than my own

I am still dealing with a bug from another question which has gone unanswered because I can't get debugging information. I have scripts running other scripts and I need to see how the tty is getting ...
1
vote
1answer
32 views

Linux Shell script to change grep for a string, then comment out 2 lines above and 1 below the string found in the file

Looking for some help on this task. I have tried several shell scripts to do this, but not sure I am approaching this problem right. I have a file that contains several blocks of data like this: ...
0
votes
1answer
44 views

how to mount chroot /proc on ubuntu start

In order to run java inside chroot environment I have to mount /proc file system using the following command mount -t proc none /proc inside the chroot environment or mount -o bind /proc /path/to/...
10
votes
3answers
5k views

vim not loading _vimrc file when launched from git bash

I have downloaded and installed git for windows (msysgit) and frequently used the included git bash. Whenever I run vim from git bash my _vimrc file is not loaded because there is syntax highlighting ...
4
votes
2answers
2k 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.
1
vote
0answers
7 views

How to use custom configuration file in combination with autostart script in Openbox?

I'm trying to use Openbox with an autostart script as well as a separate copy of "rc.xml" (this is to be able to have multiple configurations on the same computer, but that's not relevant). Let's say ...
5
votes
3answers
5k views

Remove all files containing a pattern

Suppose I have a directory with files and subdirectories underneath it. Some of the files contain a pattern "^File:" in their contents. Is there some way I can use grep and a bash command to remove ...
-1
votes
1answer
11 views

Apply the “expand” command to a file in-place like sed -i

The expand command does not have the equivalent of sed -i <file> expand actually does have a -i option - but it means only after blanks Is there a sed - expand dynamic duo combination ...
0
votes
1answer
16 views

Highlight selected words in Linux Command Usage Doc

What I want to do is print a command-help (viz. "ls --help") and grep the output for any specific word. Consider the following: ls --help | grep 'F' But what this does is just filter out the other ...
1
vote
1answer
247 views

Gem Installs not executing after update system-wide update Arch Linux

When trying to execute sass --watch scss:css inside of a target folder I get returned the message command not found I know I had sass installed. gem list doesn't show that it's installed anymore. I ...
-2
votes
1answer
18 views

Syntax error whenever I execute this code

Whenever I execute this code I get the error syntax error near else. Here is the code: if [ -z $loc ] then      if [uname -a| grep 64 >/dev/null] then         sdir=$KALDI_ROOT/tools/srilm/bin/...
2
votes
1answer
42 views

Command line 7-Zip exclude

I have tried this many times, but not yet got it. How do I use 7-Zip to zip a directory without one directory inside other? Like: I have a folder /home/files/ and inside that, directory1/ and ...
2
votes
1answer
78 views

/dev/tty: no such device or address - only in a script

I'm pulling my hair out over this. I've looked over all of the google results for /dev/tty : no such device or address, none of them apply to what I am doing / none of the solutions are successful. I ...