LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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, 06:41 AM   #1
hashbangbinbash
Member
 
Registered: Mar 2008
Posts: 108

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, 06:53 AM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
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, 07:04 AM   #3
hashbangbinbash
Member
 
Registered: Mar 2008
Posts: 108

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 07:05 AM.
 
Old 04-15-2008, 07:30 AM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
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, 08:03 AM   #5
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
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



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:14 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
Open Source Consulting | Domain Registration