Shell Scripting First Lab: Create First Shell Script

Hi All ,

Lab: Creating your first shell script

I have created a shell script and added the commands ( PFA image ) . Still the task is failing. Can someone guide me as why this is failing ?

Thanks,
Rakesh

1 Like

Hello, Raki3101
Have you still facing the issue?

You need to read the instructions again, your script is named slightly differently to what it has asked you to create (you have added a bit that is not needed)

Thanks Rosarch. I got it what the mistake is. I need to save it as a command without .sh extension to the script.

Same lab not working for. Appreciate your help.

ob@caleston-lp10:~$ cat create-and-launch-rocketcat: create-and-launch-rocket: No such file or directory
bob@caleston-lp10:~$ cat create-and-launch-rocket.sh
cat: create-and-launch-rocket.sh: No such file or directory
bob@caleston-lp10:~$
bob@caleston-lp10:~$ echo $PATH/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
bob@caleston-lp10:~$ export PATH=$PATH:/home/bob
bob@caleston-lp10:~$ which create-and-launch-rocket
bob@caleston-lp10:~$ which create-and-launch-rocket
bob@caleston-lp10:~$

This lab is not working for me. I tried it couple of times per instruction. Appreciate your help.

Hello, @Jhasujay
I think you are doing wrong way. You have to use vi editor to write command into the file create-and-launch-rocket.
First you can create file with the touch command.

touch create-and-launch-rocket

then use vi editor.

vi create-and-launch-rocket

OR
You can use direct vi editor.

vi create-and-launch-rocket

Hope it will help.

1 Like

Thank you for your quick response. It worked. I am new to Linux/Shell scripting …:slight_smile:

Hi All;
At bellow lab;

Create a shell script in the home directory called create-directory-structure.sh. The script should do the following tasks:

  1. Create the following directories under /home/bob/countries - USA, UK, India
  2. Create a file under each directory by the name capital.txt
  3. Add the capital cities name in the file - Washington, D.C, London, New Delhi
  4. Print uptime of the system

when ı wanna run script ı saw on cli

bob@caleston-lp10:/home$ create-directory-structure.sh
05:22:45 up 1:01, 0 users, load average: 3.07, 2.82, 3.17

I saw every step made by script

I made also

echo $PATH
then
export PATH=$PATH:/home

But at the end

Script did not run successfully. Please inspect your script and try again.

ıs there any one live same problem?


Hi After adding the last line directories are getting deleted.

Any solution ?

My bad I found that !

Thanks :slight_smile: