I have created following file with name test.sh#!/bin/bashname = Elvin John Paulecho $nameecho ${name#* }echo ${name##* }echo ${name% *}echo ${name%% *}and I am getting some error as below.can anyone tell me what wrong I am doing?
How to run bash on CYGWIN
bash;cygwin
There are two things wrong:You cannot use spaces around the assignment operator. As your script currently is, bash interprets the line to mean run name with the arguments = and Elvin John Paul. The line should look like the following:name=Elvin John PaulYou have Windows-style line endings (CRLF instead of just LF), which results in the error about $'\r'. In recent Cygwin versions, you can use set -o igncr to ignore carriage returns as part of a CR LF, or you can fix this with sed like so:sed 's/\r$//' file > file2