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.


11554 questions
12 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
  • 8,338
  • 4
  • 25
  • 21
6 answers

Difference between .bashrc and .bash_profile

What's the difference between .bashrc and .bash_profile and which one should I use?
  • 8,973
  • 11
  • 37
  • 42
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,971
  • 3
  • 19
  • 10
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…
  • 4,743
  • 3
  • 12
  • 9
11 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).
  • 4,541
  • 3
  • 18
  • 6
20 answers

How to encode base64 via command line?

Is there a terminal command in Mac OS X which will base64 encode a file or stdin?
  • 9,487
  • 11
  • 49
  • 70
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…
13 answers

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

Can I search history in bash and run the result?
Richard Hoskins
  • 12,245
  • 10
  • 49
  • 52
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,789
  • 8
  • 32
  • 35
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,892
  • 2
  • 16
  • 8
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?
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…
  • 14,496
  • 18
  • 73
  • 119
5 answers

Linux Bash Script, Single Command But Multiple Lines?

I have the following script I wrote by searching Google, and it backs up my Linux system to an archive: #!/bin/bash # init DATE=$(date +20%y%m%d) tar -cvpzf /share/Recovery/Snapshots/$HOSTNAME_$DATE.tar.gz --exclude=/proc --exclude=/lost+found…
Jay LaCroix
  • 2,411
  • 2
  • 13
  • 5
12 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,471
  • 4
  • 19
  • 11
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,606
  • 5
  • 29
  • 33
2 3
99 100