CD dans le script shell ne fonctionne pas
Question
Tout d'abord, je suis très très nouveau dans les scripts shell.J'essaie d'écrire un script qui prend en un paramètre, puis copie un dossier dans un répertoire différent de la nommer à l'aide du paramètre.C'est le code actuel que j'ai:
#!/bin/sh
cd /var/www/html/fbplugin/chrome
sudo mkdir temp/$1
sudo cp -rf "/var/www/html/fbplugin/chrome/fbplugin" "/var/www/html/fbplugin/chrome/temp/$1"
Quand j'exécute ce code, il est indiqué
Si cela importe pour exécuter le script, je tape "sh build.sh"
La solution
If that directory really exists, then you must have executed that script with a different user (cron, webserver, etc).
Check the rights for that directory.
Autres conseils
I don't know why you're getting the error about cd, but it looks like you could just use absolute paths throughout. That would solve the larger problem of the script working correctly.