Unable to understand string in .bashrc

I found the following code in someone .bashrc

# Source global definitions 
[ -f /etc/bashrc ] && . /etc/bashrc

This seems to have caused a lot of Bash repetitions.

What does a single-line font mean?

+2
source share
4 answers

What may confuse you: [- this is really a Unix shell command. You can find it in /bin, and when you look more closely, this is a hard link to the command test, which means you can also write:

test -f /etc/bashrc && source /etc/bashrc

( .is a shortcut for source).

: Unix , , "", . Unix, . : Unix , , .

, : , .

/dev, tty, , .

[EDIT] , [ test - :

. ls -il [ test echo :

356954 -r-xr-xr-x 2 root wheel 46K May 31 2008 [
356954 -r-xr-xr-x 2 root wheel 46K May 31 2008 test
67392  -rwxr-xr-x 1 root wheel 18K Sep 22 2007 echo

-, "2" "root". , ( a.k.a), (Unix lingo: inode, i- node "index node" ). inode , (356954). , [ test , echo .

, , . inode ( find /path -inode 356954)

[EDIT2] tty : . - "c", " ". "-" "d" "b" (, , ..). , . , ( "" - "" ) . , Unix API - "IO control" ( ioctl) (, ).

( "Ctrl-Alt-F1" ), - :

Welcome to .... - Kernel .... (tty1)

( Alt-F2... Alt-F6), , tty2 tty6.

echo test > /dev/tty1

, tty1. tty , ( mingetty, login bash ). read line < /dev/tty1, , , .

+8

/etc/bashrc , . dot "source".

+11

/etc/bashrc (-f operator), .

, && ( ) , true ( ). , , !

It is actually called the "AND list construct."

Contact here for more information.

You can also consider the following commonly used example:

make && make install

It is installed only if make completed successfully.

+8
source

I'm not sure why you didn’t ask here :) http://comments.pixelbeat.org/settings/

A more detailed equivalent of this command:

if test -r /etc/bashrc; then
 source /etc/bashrc
fi
+2
source

All Articles