Questions tagged [bash]
Bash is a free shell for Unix-like operating systems from the GNU Project.
11,779
questions
803
votes
13
answers
860k
views
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 ...
568
votes
6
answers
209k
views
Difference between .bashrc and .bash_profile
What's the difference between .bashrc and .bash_profile and which one should I use?
497
votes
11
answers
1.3m
views
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/<username>
When I ls this directory, I see the directories Desktop, Documents, etc. that I can see ...
491
votes
7
answers
261k
views
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
461
votes
11
answers
559k
views
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 ...
433
votes
19
answers
704k
views
How to encode base64 via command line in macOS/OS X?
Is there a terminal command in macOS/OS X which will base64 encode a file or stdin?
403
votes
21
answers
565k
views
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 ...
397
votes
13
answers
289k
views
How can I search the bash history and rerun a command?
Can I search history in bash and run the result?
391
votes
4
answers
685k
views
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:
...
389
votes
5
answers
514k
views
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 ...
372
votes
10
answers
384k
views
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:...
258
votes
5
answers
473k
views
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_$...
249
votes
11
answers
373k
views
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 ...
242
votes
6
answers
156k
views
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 ...
236
votes
3
answers
98k
views
What does the 'rc' in `.bashrc`, etc. mean? [duplicate]
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 ...