LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 05-02-2008, 09:20 PM   #1
lambchops468
Member
 
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:

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.

Last edited by lambchops468; 05-02-2008 at 09:21 PM.
 
Old 05-02-2008, 11:24 PM   #2
duryodhan
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, 10:26 AM   #3
lambchops468
Member
 
Registered: Mar 2007
Location: New Jersey, USA
Distribution: Archlinux
Posts: 165

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


Reply

Tags
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 12:51 AM
simple shall programming question itz2000 Programming 1 11-05-2005 04:12 PM
simple question on shell programming stupid_guy Programming 5 03-10-2004 02:07 PM
Simple C Programming Question.. Bolt Programming 6 06-03-2003 12:05 PM


All times are GMT -5. The time now is 08:00 AM.

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