Questions tagged [bash]

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

A shell is a command line environment that allows advanced scripting. It is provided on many (all?) operating systems based on or inspired by Unix. Notable OS's are Mac OS X, BSD, Solaris and the different flavours of Linux.

Bash is such a shell created in 1987 to fix some of the problems of the older Bourne Shell. The Bash command syntax is a superset of the Bourne shell command syntax and almost all Bourne shell scripts can be executed by Bash without modification. Bash stands for Bourne Again Shell.

Website: http://www.gnu.org/software/bash/bash.html

10945 questions
703
votes
11 answers

What does 'source' do?

$ whatis source source: nothing appropriate. $ man source No manual entry for source $ source bash: source: filename argument required source: usage: source filename [arguments] It exists, and it is runnable. Why isn't there any documentation about…
Andrea Ambu
  • 7,670
  • 4
  • 23
  • 20
531
votes
6 answers

Difference between .bashrc and .bash_profile

What's the difference between .bashrc and .bash_profile and which one should I use?
cfischer
  • 8,693
  • 11
  • 35
  • 42
414
votes
7 answers

What is the difference between executing a Bash script vs sourcing it?

What is the difference between executing a Bash script like A and sourcing a Bash script like B? A > ./myscript B > source myscript
Scottie T
  • 4,341
  • 3
  • 17
  • 10
390
votes
10 answers

How do I add text to the beginning of a file in Bash?

Hi I want to prepend text to a file. For example I want to add tasks to the beginning of a todo.txt file. I am aware of echo 'task goes here' >> todo.txt but that adds the line to the end of the file (not what I want).
user479534
  • 4,111
  • 3
  • 16
  • 6
358
votes
12 answers

How can I search the bash history and rerun a command?

Can I search history in bash and run the result?
Richard Hoskins
  • 11,604
  • 10
  • 47
  • 52
357
votes
10 answers

chown is not changing symbolic link

I'm trying to change the user/group of a symbolic link with the command: $ chown -h myuser:mygroup mysymbolic/ But it's not changing. I'm logged in as root. The current user/group is set to root:root. What went wrong?
rizidoro
356
votes
21 answers

How do I detach a process from Terminal, entirely?

I use Tilda (drop-down terminal) on Ubuntu as my "command central" - pretty much the way others might use GNOME Do, Quicksilver or Launchy. However, I'm struggling with how to completely detach a process (e.g. Firefox) from the terminal it's been…
AnC
346
votes
11 answers

What is the home directory on Windows Subsystem for Linux?

When I start bash on Windows Subsystem for Linux, it drops me in the directory /mnt/c/Users/ When I ls this directory, I see the directories Desktop, Documents, etc. that I can see are in C:\Users\ using the Windows File…
bcf
  • 3,603
  • 3
  • 11
  • 9
342
votes
4 answers

Go back to previous directory in shell

Is there a way to go back to previous directory we were in using bash,tcsh without using pushd/popd ? I'd like to type something like "back" and got returned to the previous directory I was in. Edit: "cd -" works, but only for current and previous…
Lydon Ch
  • 5,319
  • 8
  • 29
  • 34
324
votes
5 answers

Bash: Iterating over lines in a variable

How does one properly iterate over lines in bash either in a variable, or from the output of a command? Simply setting the IFS variable to a new line works for the output of a command but not when processing a variable that contains new lines. For…
Alex Spurling
  • 3,402
  • 2
  • 15
  • 7
227
votes
6 answers

In bash, how do I escape an exclamation mark?

I want to do something like bzr commit -m "It works!". I can sort of escape the exclamation mark by doing bzr commit -m "It works\!". However, then my commit message includes the backslash. How do I escape the exclamation mark, while still ignoring…
Matthew
  • 13,656
  • 15
  • 69
  • 115
213
votes
4 answers

Using watch with pipes

I'd like to run this command: watch -n 1 tail -n 200 log/site_dev.log | grep Doctrine But it does not run, because "I think" that the grep tries to run on the watch instead of the tail... Is there a way to do something like watch -n 1 (tail -n 200…
Tommy B.
  • 2,479
  • 3
  • 19
  • 17
212
votes
10 answers

What to do when Ctrl + C can't kill a process?

Ctrl + C doesn't always work to kill the current process (for instance, if that process is busy in certain network operations). In that case, you just see "^C" by your cursor and can't do much else. What's the easiest way to force that process to…
Dustin Boswell
  • 2,231
  • 4
  • 18
  • 11
210
votes
7 answers

Why does Ctrl + V not paste in Bash (Linux shell)?

When I copy something to the clipboard and press Ctrl + V in Bash, nothing happens; However, right clicking and selecting Paste does the job. Why? Is there any reasonable issue (I'm sure there is) behind this behavior in Linux?
Yasser Zamani
  • 2,537
  • 2
  • 14
  • 15
208
votes
3 answers

What does the 'rc' in `.bashrc`, etc. mean?

Well, this is embarrassing. I feel like I just realised I don't know a loyal colleague's name after working with them for 10 years. "Hey, er... *cough!*, thanks for that great job you did on setting my aliases this morning..." What do the letters rc…
Ian Mackinnon
  • 5,306
  • 5
  • 26
  • 33
1
2 3
99 100