The bash man page says:
"When an interactive shell that is not a login shell is started, bash reads and executes commands from /etc/bash.bashrc and ~/.bashrc, "
I can see that bash.bashrc is executed because I put echo in it, but .bashrc is not.
On one of my Ubuntu 11.10 servers, when I use sudo -i to become the root user, root's .bashrc is not being executed.
When I log in to my Ubuntu 12.04 LTS server my bash aliases aren't applied, but if I execute bash from the command line they are.
~/.profile executes ~/.bashrc:
if [ "$BASH" ]; then
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
fi
, which in turn executes ~/.bash_aliases:
if [ -f ~/.bash_aliases ]; then
.
My /etc/profile code is:
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).
if [ "$PS1" ]; then
if [ "$BASH" ] && [ "$BASH" != "/bin/sh" ]; then
# The file bash.bashrc already sets the default PS1.
# PS1='\h:\w\$ '
if [ -f /etc/bash.bashrc ]; then
.
I am making a script to simplify my daily tasks. Everyday, I have to grep for a few things inside a company server. It was okay, however, now, they have segregated each object into sub directories. I am looking for a solution in which my existing shell script will execute repeatedly into each sub directory inside a certain directory. How do I do this?
When I log in, appears the following error:
-bash: /etc/profile: line 1: syntax error near unexpected token ('
Inside the file there is the next code:
n# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))\n
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).\n\nif
[ -d /etc/profile.d ]; then\nfor i in /etc/profile.d/*.sh; do\nif [ -r $i ];
then\n.
How may I know if a script is either written in bash or sh?
The first line of the script mean nothing, since on Linux, bash script has this line:
#!bin/sh
Actually, there are many distribution where bin/sh is bash (maybe a bin/sh is a link to bin/bash in those distro), and not bourn shell.
I was wondering if there are any tutorials for generic shell concepts.
Things like what really happens underneath some fundamental commands in the shell.
Some few things i'd like inside the tutorial:
what really is an environment?
what happens to your env if you spawn another instance of bash? does it reset everything or load the defaults?
when do you use .bashrc or .bash_profile?
This question is a sequel of sorts to my earlier question. The users on this site kindly helped me determine how to write a bash for loop that iterates over string values. For example, suppose that a loop control variable fname iterates over the strings "a.txt" "b.txt" "c.txt". I would like to echo "yes!" when fname has the value "a.txt" or "c.txt", and echo "no!" otherwise.