Re: Help on bash script?

2005-08-13 Thread Ian Smith
On Sat, 13 Aug 2005, Giorgos Keramidas wrote: On 2005-08-12 13:38, Benson Wong [EMAIL PROTECTED] wrote: I prefer: for COREFILE in `find / -type f -name core -print` do ... done Wouldn't that accomplish the same thing? More or less. Less, when the filenames are

Help on bash script?

2005-08-12 Thread Ian Smith
On Fri 12 Aug 2005 09:33:54 +0800 Xu Qiang [EMAIL PROTECTED] wrote: find / -type f -name core -print | while read COREFILE ; do NCOREFILES=$[ $NCOREFILES + 1 ] # a bit strange - xq echo $NCOREFILES # xq

Re: Help on bash script?

2005-08-12 Thread Benson Wong
I prefer: for COREFILE in `find / -type f -name core -print` do ... done Wouldn't that accomplish the same thing? On 8/12/05, Ian Smith [EMAIL PROTECTED] wrote: On Fri 12 Aug 2005 09:33:54 +0800 Xu Qiang [EMAIL PROTECTED] wrote: find / -type f -name core -print | while

Re: Help on bash script?

2005-08-12 Thread Giorgos Keramidas
On 2005-08-12 13:38, Benson Wong [EMAIL PROTECTED] wrote: I prefer: for COREFILE in `find / -type f -name core -print` do ... done Wouldn't that accomplish the same thing? More or less. Less, when the filenames are too many. See questions posted on this very same list about ``too many

Help on bash script?

2005-08-11 Thread Xu Qiang
Hi, all: I don't know if this is the right list to ask this question. But since I didn't find a bash script mail list and you guys are always so helpful, then... Here are an excerpt of a bash script: --- #!/bin/bash # saveLogs.sh - Bourne

Re: Help on bash script?

2005-08-11 Thread dpk
On Fri, 12 Aug 2005, Xu Qiang wrote: Hi, all: I don't know if this is the right list to ask this question. But since I didn't find a bash script mail list and you guys are always so helpful, then... Here are an excerpt of a bash script:

RE: Help on bash script?

2005-08-11 Thread Xu Qiang
dpk wrote: On Fri, 12 Aug 2005, Xu Qiang wrote: As soon as you used the pipe, to the while, you entered a sub-shell. There's no way (that I'm aware of anyways) to get the sub-shell's variables sent back up to the parent. Thanks for your detailed analysis and a solution. Yes, I didn't notice

Re: Help on bash script?

2005-08-11 Thread Giorgos Keramidas
On 2005-08-12 10:16, Xu Qiang [EMAIL PROTECTED] wrote: Btw, can we export a value in the sub-shell back to the parent? Only through `backquote subtitution', as the child process cannot affect the environment of the parent process. value=`shell command` value=$(shell command)

RE: Help on bash script?

2005-08-11 Thread Xu Qiang
Giorgos Keramidas wrote: On 2005-08-12 10:16, Xu Qiang [EMAIL PROTECTED] wrote: Btw, can we export a value in the sub-shell back to the parent? Only through `backquote subtitution', as the child process cannot affect the environment of the parent process. value=`shell command`

RE: Help on bash script?

2005-08-11 Thread Xu Qiang
dpk wrote: On Fri, 12 Aug 2005, Xu Qiang wrote: 1. The way of incrementing the variable NCOREFILES. Why does it use the formula of NCOREFILES=$[ $NCOREFILES + 1 ], and not the direct way of NCOREFILES=$NCOREFILES+1? If that was done, NCOREFILES would end up looking like: +1+1+1+1+1+1+1

RE: Help on bash script?

2005-08-11 Thread Xu Qiang
This is my test script: - #!/bin/bash var=0 var=$[3] vari=0 ++vari echo $var echo $vari - The result is: ./test.sh: ++vari: command not found 3 0 So the manual of bash is incorrect? Regards, Xu Qiang

RE: Help on bash script?

2005-08-11 Thread dpk
On Fri, 12 Aug 2005, Xu Qiang wrote: This is my test script: - #!/bin/bash var=0 var=$[3] vari=0 ++vari echo $var echo $vari - The result is: ./test.sh: ++vari: command not found 3 0 So the manual of bash is incorrect? Regards, Xu

RE: Help on bash script?

2005-08-11 Thread Xu Qiang
dpk wrote: It will work with either 'let' or within an 'arithmetic expansion': $[++var] let ++var By the way, there is another syntax, from the man page, that seems to operate identically: $((++var)) and $((var+1)) With let ++var, the result is still 0, it isn't incremented. With