I am trying to retrieve all the files(no directories) which doesn't end with .txt and store it in a variable or array.
My command is running properly in the command line. I don't have any editor in the unix server(aws). so I am writing script in windows notepad++(EOL conversion unix) and copying the script into the server and running the script from command line. I am getting a syntactical error.
PFB code:
#!/bin/bash
var1=$(ls -p !(*.sh) | grep -v /)
echo $var1
Error:
./test4.sh: command substitution: line 3: syntax error near unexpected token `('
./test4.sh: command substitution: line 3: `ls -p !(*.sh)|grep -v /)'