Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
Pages: (6) </ 1 2 3 4 [5] 6 >/

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: Beta testers needed, bash script testing< Next Oldest | Next Newest >
curaga Offline





Group: Members
Posts: 2163
Joined: Feb. 2007
Posted: Jan. 30 2008,17:22 QUOTE

I read somewhere that some versions of bash can only use -z with number variables.

Try:

if [ ! -n "$MEMINFO" ]

aka not not null.


--------------
There's no such thing as life. Those mean little jocks invented it ;)
-
Windows is not a virus. A virus does something!
Back to top
Profile PM 
^thehatsrule^ Offline





Group: Members
Posts: 3275
Joined: July 2006
Posted: Jan. 30 2008,17:23 QUOTE

I think that's because $() uses a subshell in order to execute the command substitution... so the variable is lost afterwards.

Since you really only need to read that file once, the easiest change would be to read it before you call that function.

EDIT: saw previous post:
Quote
I read somewhere that some versions of bash can only use -z with number variables.

Try:

if [ ! -n "$MEMINFO" ]

aka not not null.
You mean for test, not bash..? Also, -z is for strings only (and if it wasn't, an error would be printed).  For the most portability, = should be used iirc.
Back to top
Profile PM 
WDef Offline





Group: Members
Posts: 798
Joined: Sep. 2005
Posted: Jan. 30 2008,23:52 QUOTE

Zucca: re using awk to do real arithmetic - I thought I did show you how to - go back and re-read my post, the same one with Perl.

Perl vs Awk: a *nix system without Perl is rare indeed.

Re: sed vs awk.  The usual rule is you try to avoid sed for anything except simple replacements, which it is usually best for.   But really, it doesn't much matter on modern processors unless an operation is in a lengthy loop or is otherwise chewing up a lot of resources.
Back to top
Profile PM 
mikshaw Offline





Group: Members
Posts: 4856
Joined: July 2004
Posted: Jan. 31 2008,00:30 QUOTE

I think the only thing I've ever used sed for was replacement. I don't even know what else it does =o)

--------------
http://www.tldp.org/LDP/intro-linux/html/index.html
Back to top
Profile PM WEB 
Zucca Offline





Group: Members
Posts: 524
Joined: Feb. 2006
Posted: Jan. 31 2008,15:06 QUOTE

Quote (^thehatsrule^ @ Jan. 30 2008,14:23)
I think that's because $() uses a subshell in order to execute the command substitution... so the variable is lost afterwards.

But I don't have any "$(command)" there.
I read that to set the variable local only you must use local -command.

But if it is really lost somewhere, is there a way to pass it to the outer process?


--------------
Do you have it? - http://dy.fi/mak
Back to top
Profile PM WEB ICQ MSN 
28 replies since Jan. 24 2008,16:16 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

Pages: (6) </ 1 2 3 4 [5] 6 >/
reply to topic new topic new poll
Quick Reply: Beta testers needed

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code