LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   Simple Shell Programming Question: [ $( )] (http://www.linuxquestions.org/questions/linux-software-2/simple-shell-programming-question-%5B-%24-%5D-639505/)

lambchops468 05-02-2008 09:20 PM

Simple Shell Programming Question: [ $( )]
 
I've been poking around Arch Linux's network scripts, and I can't seem to figure these lines out:

Code:

[ "$(/sbin/ifconfig ${1} 2>/dev/null | /bin/grep -v 'inet6 addr: fe80:' | /bin/grep -e 'inet addr:' -e 'inet6 addr')" ] && return 0
(these lines are to find out if an interface is up. The return exits the function that would bring the interface up if the interface were running)

I know what everything does execpt $(/sbin/ifconfig ${1} 2>/dev/null)

why is this in $() and that inside []?

these parentheses with a dollar sign in front is confusing me.

duryodhan 05-02-2008 11:24 PM

$(command) is same as the backtick symbol used in earlier versions .

for e.g
instead of

for file in `ls`

I can do
for file in $(ls)

lambchops468 05-03-2008 10:26 AM

Thanks. Thats all I need to know.


All times are GMT -5. The time now is 02:55 PM.