I want to execute following command in shell script
cp /somedire/*.(txt|xml|xsd) /destination/dir/
But this does not run inside shell script. Any quick help?
createjob.sh: line 11: syntax error near unexpected token `(‘
My shell is zsh.
Thanks
Nayn
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Your use of parentheses and alternation is a zsh-specific construct. It doesn’t work in other shells, including zsh in sh compatibility mode.
If you want to keep using this construct, you’ll have to invoke zsh as zsh (presumably by replacing
#!/bin/shby#!/bin/zshor something like that).If you need your script to run on ksh, use
#!/bin/kshor#!/usr/bin/env kshandIf you also need to support bash, that same command with the
@will work provided you run the following commands first:If you need POSIX sh compatibility, you’ll have to use three separate commands, and prepare for an error message if any of the three extensions has no match. A more robust solution would use find: