Go Job Hunting at the LQ Job Marketplace
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 05-02-2008, 10:20 PM   #1
Registered: Mar 2007
Location: New Jersey, USA
Distribution: Archlinux
Posts: 165

Rep: Reputation: 30
Simple Shell Programming Question: [ $( )]

I've been poking around Arch Linux's network scripts, and I can't seem to figure these lines out:

[ "$(/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.

Last edited by lambchops468; 05-02-2008 at 10:21 PM.
Old 05-03-2008, 12:24 AM   #2
Senior Member
Registered: Oct 2006
Distribution: Slackware 12 Kernel 2.6.24 - probably upgraded by now
Posts: 1,054

Rep: Reputation: 46
$(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)
Old 05-03-2008, 11:26 AM   #3
Registered: Mar 2007
Location: New Jersey, USA
Distribution: Archlinux
Posts: 165

Original Poster
Rep: Reputation: 30
Thanks. Thats all I need to know.


programming, script, scripting, shell, variable

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
a simple question about module programming linwenyuan Linux - Kernel 2 11-24-2006 01:51 AM
simple shall programming question itz2000 Programming 1 11-05-2005 05:12 PM
simple question on shell programming stupid_guy Programming 5 03-10-2004 03:07 PM
Simple C Programming Question.. Bolt Programming 6 06-03-2003 01:05 PM

All times are GMT -5. The time now is 05:25 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration