I do this in a script:
read direc <<< $(basename `pwd`)
and I get:
Syntax error: redirection unexpected
in an ubuntu machine
/bin/bash --version
GNU bash, version 4.0.33(1)-release (x86_64-pc-linux-gnu)
while I do not get this error in another suse machine:
/bin/bash --version
GNU bash, version 3.2.39(1)-release (x86_64-suse-linux-gnu)
Copyright (C) 2007 Free Software Foundation, Inc.
Why the error?
Does your script reference
/bin/bashor/bin/shin its hash bang line? The default system shell in Ubuntu is dash, not bash, so if you have#!/bin/shthen your script will be using a different shell than you expect. Dash does not have the<<<redirection operator.Make sure the shebang line is:
or
And run the script with:
Do not run it with an explicit
shas that will ignore the shebang: