LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-15-2008, 07:41 AM   #1
hashbangbinbash
Member
 
Registered: Mar 2008
Posts: 106

Rep: Reputation: 16
bash syntax problems


I have a similar question about the correct syntax for this scriptlet:

Code:
#!/bin/bash
n=( date | awk '{print $3 }')
if ($n =< 7)
 echo "do the thing"
done.
can't quite find the answer through google.
 
Old 04-15-2008, 07:53 AM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Quote:
Originally Posted by hashbangbinbash View Post
I have a similar question about the correct syntax for this scriptlet:

Code:
#!/bin/bash
n=( date | awk '{print $3 }')
if ($n =< 7)
 echo "do the thing"
done.
can't quite find the answer through google.
How is this similar to the OP asking about ping??!! (It's better to put into your own thread)

What is the question?
One thing I see is the assignment of the result of a command. It needs to be one of 2 forms:
n=$(command)
n=`command`
(those are back-tics, not single quotes)
 
Old 04-15-2008, 08:04 AM   #3
hashbangbinbash
Member
 
Registered: Mar 2008
Posts: 106

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by pixellany View Post
How is this similar to the OP asking about ping??!! (It's better to put into your own thread)

What is the question?
One thing I see is the assignment of the result of a command. It needs to be one of 2 forms:
n=$(command)
n=`command`
(those are back-tics, not single quotes)
it's a question about bash scripting where a condition is tested and a command results from that condition. Is there any diffefrence with back-ticks and "$()"?

Last edited by hashbangbinbash; 04-15-2008 at 08:05 AM.
 
Old 04-15-2008, 08:30 AM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Quote:
Originally Posted by hashbangbinbash View Post
it's a question about bash scripting where a condition is tested and a command results from that condition. Is there any difference with back-ticks and "$()"?
Why not try it?

(No, they do exactly the same thing)
 
Old 04-15-2008, 09:03 AM   #5
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
Quote:
Originally Posted by hashbangbinbash View Post
it's a question about bash scripting where a condition is tested and a command results from that condition. Is there any diffefrence with back-ticks and "$()"?
You can have an expression with $() inside another expression in $().
 
  


Reply


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
bash, syntax error santana Linux - Software 2 01-23-2008 02:39 PM
bash syntax Sushy Programming 1 06-04-2007 07:25 PM
bash-3.1 bug or syntax error? moszern Linux - Software 1 06-12-2006 01:57 PM
BASH : syntax error semaja2 Programming 6 01-26-2006 01:33 AM
explanation on some bash syntax slzckboy Programming 2 10-02-2005 07:06 AM


All times are GMT -5. The time now is 07:18 AM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration