Answer the question
In order to leave comments, you need to log in
Why doesn't a bash script navigate to a directory by parameter?
Hello! I am a beginner web developer. OS: Ubuntu 18.04
Recently encountered a problem: too lazy to manually create several directories and files with different extensions. That is, for each project, I have to make a directory, naming it with the name of the project, inside another 3-4 directories, with their own names, in each directory there are 1-2 files in different extensions, the names are always the same. It is much more convenient to do all this through the terminal, because the terminal has touch, but GNOME "create a text file" does not.
I decided to make a bash script. I used to do very, very simple ones, but here, I thought, it was not more difficult. The script has not been completed yet, because at startup it does not go to the specified directory. Why?
Here is the code:
#!/bin/bash
adress=$1
newFolderName=$2
cd
cd $1
[email protected]:~$ chmod +x dirCreater.sh
[email protected]:~$ ./dirCreater.sh Документы
[email protected]:~$ ./dirCreater.sh Документы/
[email protected]:~$ ./dirCreater.sh /Документы
./dirCreater.sh: строка 5: cd: /Документы: Нет такого файла или каталога
[email protected]:~$ ls
Общедоступные Android 'VirtualBox VMs' 'Рабочий стол'
Видео dirCreater.sh Документы Шаблоны MW Загрузки
file.py Изображения netbeans-8.2 ScanResult2.txt Музыка
[email protected]:~$ ./dirCreater.sh Документы
[email protected]:~$
Answer the question
In order to leave comments, you need to log in
Passes, but inside the script environment. To check - just call pwd in the script
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question