cancel
Showing results for 
Search instead for 
Did you mean: 
hedai710
Mission Specialist
Mission Specialist
  • 308 Views

RHCSA II Section 1 2.2 first bash script

Jump to solution

I have this exactly as it says on #2  but I don't get any return command from bash  firstscript.sh  //   is there a typo in the command provided or??? am I a Potatoe

Create and execute a simple Bash script.

  1. Use the vim command to create the firstscript.sh file under your home directory.

    [student@servera ~]$ vim firstscript.sh
  2. Insert the following text, and save the file. The number of hash signs (#) is arbitrary.

    #!/usr/bin/bash
    echo "This is my first bash script" > ~/output.txt
    echo "" >> ~/output.txt
    echo "#####################################################" >> ~/output.txt
  3. Use the bash command to execute the script.

    [student@servera ~]$ bash firstscript.sh
10 Replies
Chetan_Tiwary_
Community Manager
Community Manager
  • 13 Views

@hedai710 you can try writing the same bash script in two steps :

1. first write it without the > or >> redirection part and run the script to see what is happening and 

2. write it with the > / >> as depicted in the course and run it to see the difference. 

 

Bash scripting is basically the commands that you write in the terminal with some logic applied to achieve a goal ! These commands can range from simple file operations to complex logic structures, enabling automation of tasks and system management.

So practice commands more with standard redirection techniques ( stdin , stdout and stderr )  and you will get the bash scripting ! 

0 Kudos
Join the discussion
You must log in to join this conversation.