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

learn more… | top users | synonyms

31
votes
5answers
23k views

How do I configure ConEmu to run Cygwin Bash?

I created a new task {Bash} passed my home directory /dir "C:\Users\TMB\" and added bash as an application C:\cygwin\bin\bash.exe When I open Bash, it is unable to use the basic UNIX/...
31
votes
1answer
6k views

How can I get bash to perform tab-completion for my aliases?

I have a bunch of bash completion scripts set up (mostly using bash-it and some manually setup). I also have a bunch of aliases setup for common tasks like gco for git checkout. Right now I can ...
30
votes
4answers
19k views

Cygwin fatal error unable to remap.. What does it mean?

When running python in cygwin, I get the following error: 0 [main] python 6140 C:\cygwin\bin\python.exe: *** fatal error - unable to remap \\?\C:\cygwin\lib\python2.6\lib-dynload\time.dll to same ...
30
votes
2answers
5k views

How can I get a specific argument from a previous command in bash?

In bash, you can use !* to get all the arguments from the previous command. As an example, if you did cp /some/path /some/other/path and then did mv !*, the second command would be expanded to mv /...
29
votes
9answers
5k views

Any shortcut for “cd ..”?

Is there any shortcut for cd ..?
29
votes
5answers
19k views

Change Terminal Title in Mac OS X

How can I arbitrarily change the title of a Terminal window in Mac OS X? I have seen this question and this magicwrap thing, but think it's just a simple Mac OS X command.
29
votes
2answers
18k views

Bash Shebang for dummies?

I have some bash scripts I have setup that mostly use #!/bin/bash but I regularly come across some that look like #!/bin/bash -e #!/bin/bash -x #!/bin/bash -ex and so on. Can someone explain ...
29
votes
3answers
12k views

Bash command to focus a specific window

Is there a way, in bash command line, to give focus to a specific window of a running process. Assume I know the process' name, number, and anything else I need. For instance, if I have a single ...
29
votes
2answers
11k views

How to rehash executables in $PATH with bash

The subject says it all, how to rehash the available executables available within one of the $PATHs after having changed things: e.g. removed a binary from one $PATH which is available in another $...
28
votes
9answers
26k views

How can I prepend a line number and tab to each line of a text file?

How can I append a line number and tab to the beginning of each line of a text file?
28
votes
7answers
66k views

'No such file or directory' error in bash, but the file exists?

On Ubuntu, I get a 'No such file or directory' error when I try to execute a command. I have checked with ls -la , the file adb is there and it has 'x' flag So why I am getting a 'No such file or ...
28
votes
6answers
25k views

How many cores I am using on a Linux Server?

I am just wondering how I can find out in bash how many CPU cores a user is now using on a Linux Server? I am submitting a fair amount of background jobs to the server, so I'd like to write a bash ...
28
votes
2answers
21k views

Avoid unwanted path in Zip file

I'm making a shell script to package some files. I'm zipping a directory like this: zip -r /Users/me/development/something/out.zip /Users/me/development/something/folder/ The problem is that the ...
28
votes
6answers
52k views

command not found when using sudo

There are a few question on the site that seem related to my problem but I could not find a solution in any of them. My operating system is Ubuntu 12.04. I have mvn installed in /tools/noarch/apache-...
28
votes
1answer
4k views

How do I reload .inputrc using a bash script?

This question explains how to reload .inputrc using C-x C-r. But how would one reload it using commands in a bash script?
27
votes
8answers
16k views

Why doesn't echo support “\e” (escape) when using the -e argument in MacOSX

When I try to print out some colored text using ANSI escape sequences via the built-in echo command, it seems that the \e escape sequence in the string I provide is interpreted literally instead of as ...
27
votes
4answers
31k views

I want to change DPI with ImageMagick without changing the actual byte-size of the image data

In GIMP there is a very simple way to do what I want. I only have the German dialog installed but I’ll try to translate it. I’m talking about going to Picture -> PrintingSize and then adjusting the ...
27
votes
5answers
15k views

What is the difference between bash and sh?

I see two types of code being used: #!/usr/bin/sh and: #!/user/bin/bash I searched for this online and opinions vary a lot. The explanations I saw on most websites say that sh is older than bash,...
27
votes
2answers
3k views

Bash autocomplete on symlink to directory complete to whole directory, including slash [duplicate]

Possible Duplicate: Tab-completion with directories/links when I've a symlink foo linking to a directory bar/ and I start typing f and hit tab, it completes to foo but I'd like to complete it ...
27
votes
1answer
4k views

Is there a way to make bash more TAB friendly?

I use bash on both my Mac and as my cygwin shell. Overall, I'm quite pleased with it. My one complaint however is that its TAB completion isn't as good as Windows Command Line TAB completion. For ...
27
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 ...
26
votes
4answers
21k views

push/pop current directory?

With bash is there a way to push and pop the current working directory? I tried writing bash;cd dir; ./dostuff;exit; but the current directory is now dir.
26
votes
3answers
83k views

Command: sudo su -

I understand what su - does logs you into root with the root environment (as opposed to su which logs you into root with your environment) And I understand what sudo does you are root for one ...
26
votes
2answers
33k views

Rename user's group name

I just did usermod -l login-name old-name to change the username, but the group name is still the old one. Any way of renaming the group name? I can't find any info to do so.
26
votes
3answers
9k views

How can I make the bash backtick operator keep newlines in output?

Is there a way to make bash not eat newlines in the backtick substitution? For example: var=`echo line one && echo line two` echo $var line one line two What I want is var=`echo line one ...
26
votes
2answers
9k views

Is there any way to get bash to have syntax highlighting like fish?

In the fish shell, the actual command line is syntax highlighted: Is there any way to get this same behavior in bash? There is something just like this but for zsh, not bash. Is it possible that ...
25
votes
2answers
33k views

How do I enter a literal tab character in a bash shell?

For example, I wanted to use the sort utility with the -t option to specify tab separators, but sort -t "\t" doesn't work.
25
votes
10answers
26k views

.bashrc not sourced in iTerm + Mac OS X

I am using iTerm in Mac OS X 10.6. It seems when i open iTerm, neither .bashrc nor .bash_profile is sourced. I can tell because the aliases defined in .bashrc don't work. How to fix?
25
votes
10answers
46k views

Filesystem full: how to find the biggest directories or biggest file? [duplicate]

Under Linux, I'm looking for a command to list the biggest file and/or the biggest directories under a directory.
25
votes
5answers
75k views

How can I change the default Python version on Snow Leopard?

I recently upgraded my Mac OS X 10.5 Leopard install to 10.6 Snow Leopard, and with that came an upgraded version of Python, 2.6.1 (instead if 2.5.1). Now when I type python in the Terminal i still ...
25
votes
5answers
10k views

Cygwin bash prompt is wrapping lines on the same line

I'm using Cygwin bash prompt, and for long commands the text will wrap around on the same line as opposed to going to the next line despite setting my PS1 to simply ' $'. Here's a screenshot,
25
votes
4answers
33k views

cURL: how to suppress strange output when redirecting?

I'm trying to print just the verbose sections of a cURL request (which are sent to stderr) from the bash shell. But when I redirect stdout like this: curl -v http://somehost/somepage > /dev/null ...
25
votes
1answer
17k views

Does rsync delete files, folders at destination by default?

Files Suppose that /foo/src contains only A.c and that /foo/dest contains both A.c and B.c. And suppose I run the following command: rsync /foo/src/ /foo/dest Will rsync erase B.c? Folders Now ...
24
votes
5answers
39k views

Continuously re-execute a command when it finishes in Bash

I'm trying to figure out a simple way to keep re-executing a command whenever it finishes, for any reason (error or otherwise). What would be the best way to approach this? EDIT: I wasn't clear ...
24
votes
2answers
2k views

Is there a one line command to make chmod interactive?

I am looking for something like: ls | ask_yes_no_for_each_file | chmod +x the_files_approved Or similar syntax. Also could work on other commands that you want individual confirmation for.
24
votes
6answers
108k views

How to upload a file from the command line with FTP or SSH?

I have never done this before and I am creating a bash shell script to do this for me. I will also be connecting via ssh to do some things (which I already know how to do). So maybe there is a way to ...
24
votes
8answers
48k views

How to write a script that accepts input from a file or from stdin?

How can one write a script that accept input from either a filename argument or from stdin? for instance, you could use less this way. one can execute less filename and equivalently cat filename | ...
24
votes
3answers
15k views

What is the difference between &> and >& in bash?

What is the difference between &> and >& in bash? tldp did not mention the latter one. Is it really a redirection operator? Or does someone know a more complete tutorial?
23
votes
4answers
58k views

Finding files which contain a certain string using find (1) and grep (1)

find . -type f -print -exec cat {} \; | grep some string Command above doesn't print the file path. I'm using: Ubuntu, bash 4.
23
votes
5answers
9k views

.profile and .bashrc doesn`t work on my Mac

This problem I have for a long time. After running terminal .profile, and .bashrc file doesn`t work (are not executed). Could you indicate where should I looking form a source of problem?
23
votes
3answers
2k views

What causes bash to pause after a bad command?

When you are typing a bad command, say you want to do: $ cd .. $ ls But instead you type too fast and end up hitting enter between l and s, so you get: $ cd .. $ l sbash: l: command not found... ...
23
votes
2answers
3k views

What is /usr/bin/[ and how do I use it?

I was looking at coreutils and found this as one of the files included as part of coreutils: /usr/bin/[. What is [ and what does it do? It is an executable. I just don't know what it does or how to ...
23
votes
5answers
32k views

How do I convert a bash array variable to a string delimited with newlines?

I want to write out a bash array variable to a file, with each element on a new line. I could do this with a for loop, but is there another (cleaner) way to join the elements with \n?
23
votes
2answers
17k views

Measure script execution time

In bash shell, is there a simple way for me to monitor the time taken to run a script and output the time taken?
22
votes
7answers
3k views

Is there a standard unix program that returns a range of numbers

Im learning shell scripting from an outdated textbook, and it seems to me like it'd be really usefull to have a program that just returns a string of numbers delimited by spaces something like $ ...
22
votes
7answers
26k views

In bash, how to sort strings with numbers in them?

If I have these files in a directory cwcch10.pdf cwcch11.pdf cwcch12.pdf cwcch13.pdf cwcch14.pdf cwcch15.pdf cwcch16.pdf cwcch17.pdf cwcch18.pdf cwcch1.pdf cwcch2.pdf cwcch3.pdf cwcch4.pdf cwcch5.pdf ...
22
votes
5answers
3k views

Finding the definition of a bash function

I work in an environment that has a lot of legacy shell script magic lying around. One thing used heavy from the command line are bash functions that get sourced from some file included from some ...
22
votes
2answers
9k views

Can the output of one command be piped to two other commands?

How can I pipe the output of one command to the input of two other commands simultaneously?
22
votes
6answers
12k views

How to verify that file2 is newer than file1 in bash?

How can I verify that file2 was last modified after file1? In this example, perl was modified more recently than stack. Is there a bash or Linux command that can compare these files based on the ...
22
votes
1answer
3k views

Why does wget give an error when executed with sudo, but works fine without?

I tried the following command: $ wget -q --tries=10 --timeout=20 --spider http://google.com (From this SO post. I want to check my internet connection in bash.) I get following output: Spider ...