function grammar

2010-07-18 Thread Linda Walsh
from man bash, to define a function use; function name compound-command OR name () compound-command right? And Compound Commands are: ( list) { list; ) (( expression )) [[ expression ]] ...et al so why do I get a syntax error for function good_dir [[ -n $1 -d $1 -r $1 -x $1

Re: Bad performance for substring replacement by pattern

2010-07-18 Thread Linda Walsh
Yi Yan wrote: Hi, I used the following Bash script to test substring replacement operator. It is performance get worse very quickly with the increasing of the string length. I test the script with Bash(4.1) on Debian Linux machine. See the execution time difference by

How to input ^J?

2010-07-18 Thread Peng Yu
Hi, I have some filenames that have the character ^J. I can not figure out a way to input such a character. Does anybody know if it is possible to input ^J? -- Regards, Peng

Re: How to input ^J?

2010-07-18 Thread Bob Proulx
Peng Yu wrote: I have some filenames that have the character ^J. I can not figure out a way to input such a character. Does anybody know if it is possible to input ^J? Several ways. One is you can quote the characters verbatim with C-v before the character. As in C-v C-j. (A.K.A. ^v ^j) But

Re: How to input ^J?

2010-07-18 Thread John Reiser
Lastly since ^J is a newline you can generate one with echo \n. That does not work in bash-4.x. Firstly, by default the bash builtin 'echo' supplies a trailing newline. Secondly, backslash translation requires the option -e. $ echo \n \n $ echo \n | od -c 000 \ n \n 003 $ What

Re: function grammar

2010-07-18 Thread Clark J. Wang
On Mon, Jul 19, 2010 at 2:53 AM, Linda Walsh b...@tlinx.org wrote: from man bash, to define a function use; function name compound-command OR name () compound-command right? And Compound Commands are: ( list) { list; ) (( expression )) [[ expression ]] ...et al so why

Re: function grammar

2010-07-18 Thread Linda Walsh
The curly brackets are suposed to be optional. They are line 2 of the Compound commands list below... Clark J. Wang wrote: On Mon, Jul 19, 2010 at 2:53 AM, Linda Walsh b...@tlinx.org mailto:b...@tlinx.org wrote: from man bash, to define a function use; function name