[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: CL function to script difficulties
From: |
Greg Wooledge |
Subject: |
Re: CL function to script difficulties |
Date: |
Fri, 19 Apr 2024 16:52:12 -0400 |
On Fri, Apr 19, 2024 at 03:15:07PM -0500, Mike McClain wrote:
> This function defined on the command line works as I wish:
> dircmp() {
> diff <(cd $1; find . -type f,l,d -printf '%p %s %t\n' | sort) \
> <(cd $2; find . -type f,l,d -printf '%p %s %t\n' | sort);
> }
> When I put the same into a script I get this error:
> dircmp: 12: Syntax error: "(" unexpected
You're using a bash feature, so make sure your script is being executed
by bash, not by /bin/sh.
If you explicitly type "sh myscript" then that's the problem right there.
Type bash instead of sh.
If you type "./myscript" or "myscript" (if PATH contains it) then the
interpreter is chosen by the shebang header. So make sure the header
is #!/bin/bash or equivalent. #!/bin/sh will not work.