Sign in to follow this  
Followers 0

confused on unix special character command

4 posts in this topic

Posted

Write a script that outputs your name. So if your name is "Joe Smith". The script should echo "Joe Smith" to the screen.

the answer is $cat tut2q1.sh

!/bin/bash

This is a script to print Joe Smiths name.

echo 'Joe Smith' $

but after i write $cat blah blah, the next command line gives me > symbol. after finish typing until the end of $, i can't get out of the sh? how do you type those command step by step?

thanks

Share this post


Link to post
Share on other sites

Posted

You have noend explained this very well

Remive the end $

And u need a # at the start of the bin bash line

Share this post


Link to post
Share on other sites

Posted

For your script to print the name, your bash script should be simply:

#!/bin/bash

echo 'Joe Smith'

However alternatively you can use the command whoami which will return the user's name: i.e.

#!/bin/bash

whoami

Share this post


Link to post
Share on other sites

Posted

Also you should really execute bash scripts by "bash tut2q1.sh", what you are doing is just writing the files contents to the console with cat

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.