aahlawat
asked on
UNIX Shell
A) How can I create a simple shell script that displays:
Hi !
This introduction to UNIX stuff isn’t bad.
I’ve enjoyed learning UNIX!
B) How can I place a formatting flag so that the line “This introduction to UNIX stuff isn’t bad” appears on the same line as “Hi!”
b) How can I add a line at the end that gives today’s date.
Explain me how can i make changes in the script if i have to. I am very confuse with these. Thank you for your time.
Hi !
This introduction to UNIX stuff isn’t bad.
I’ve enjoyed learning UNIX!
B) How can I place a formatting flag so that the line “This introduction to UNIX stuff isn’t bad” appears on the same line as “Hi!”
b) How can I add a line at the end that gives today’s date.
Explain me how can i make changes in the script if i have to. I am very confuse with these. Thank you for your time.
Ditto - what Sunnycoder said.
Also check out "date".
That and echo are all you need.
It's a course - look in your textbook and do the script, so you learn about it.
After the course and some experience, come back here and answer some questions!
Also check out "date".
That and echo are all you need.
It's a course - look in your textbook and do the script, so you learn about it.
After the course and some experience, come back here and answer some questions!
Also don't forget the man command.
man <command>
Will give you a man page for the command.
man <command>
Will give you a man page for the command.
start vi
# vi newscript
then press i (insert) and copy this
echo -n "Hi! "
echo "This introduction to UNIX stuff isn’t bad"
date
then ESC and :wq to write the new file
then you must change the modes of your script
# chmod 0775 newscipt
and execute it
# ./newscript
# vi newscript
then press i (insert) and copy this
echo -n "Hi! "
echo "This introduction to UNIX stuff isn’t bad"
date
then ESC and :wq to write the new file
then you must change the modes of your script
# chmod 0775 newscipt
and execute it
# ./newscript
if changes needed then run again
# vi newscript
and 1) add lines pressing o
2) delete lines d
3) add chars i + ESC when done
4) delete chars x
hop that helps
# vi newscript
and 1) add lines pressing o
2) delete lines d
3) add chars i + ESC when done
4) delete chars x
hop that helps
Assuming that you are completely new to unix, I am posting here some
'c' shell ( csh ) examples. This is nothing more than what others have
suggested so far.
Remember: In unix 'man' is your friend. To invoke help on any command
use 'man'. Say command is 'date'
prompt> man date
A) How can I create a simple shell script that displays:
Hi !
This introduction to UNIX stuff isn’t bad.
I’ve enjoyed learning UNIX!
--------------------------
#! /bin/csh -f
echo Hi !
echo
echo This introduction to UNIX stuff isn’t bad.
echo
echo I’ve enjoyed learning UNIX!
--------------------------
B) How can I place a formatting flag so that the line “This introduction to UNIX stuff isn’t bad” appears on the same line as “Hi!”
--------------------------
#! /bin/csh -f
echo -n Hi !
echo This introduction to UNIX stuff isn’t bad.
echo
echo I’ve enjoyed learning UNIX!
--------------------------
b) How can I add a line at the end that gives today’s date.
--------------------------
#! /bin/csh -f
echo -n Hi !
echo This introduction to UNIX stuff isn’t bad.
echo
echo I’ve enjoyed learning UNIX! `date`
--------------------------
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sounds too much like beginners course work .... look into following commands
echo
stat
cat
redirection using >, < and >>
this is simple stuff which you should be able to figure out in no time
Sunnycoder