Jump to content

Question

Posted

[color=#000000][font=Arial,]
Write a script that outputs your name. So if your name is "Joe Smith". The script should echo "Joe Smith" to the screen.[/font][/color][color=#000000][font=Arial,]
the answer is $cat tut2q1.sh[/font][/color]
[b] [size=3]!/bin/bash[/size][/b]

[b] [size=3]This is a script to print Joe Smiths name.[/size][/b]
[color=#000000][font=Arial,]
echo 'Joe Smith' $[/font][/color][color=#000000][font=Arial,]
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?[/font][/color][color=#000000][font=Arial,]
thanks[/font][/color]

Share this post


Link to post
Share on other sites

3 answers to this question

  • 0

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
  • 0

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
  • 0

Posted

Also you should really execute bash scripts by "bash [color=#000000][font=Arial,]tut2q1.sh", what you are doing is just writing the files contents to the console with cat[/font][/color]

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.