?
Solved

UNIX Shell

Posted on 2004-08-27
8
Medium Priority
?
514 Views
Last Modified: 2010-04-21
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.

0
Comment
Question by:aahlawat
7 Comments
 
LVL 45

Expert Comment

by:sunnycoder
ID: 11914049
Hi aahlawat,

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

Expert Comment

by:CajunBill
ID: 11919363
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!
0
 
LVL 1

Expert Comment

by:Robnhood
ID: 11969323
Also don't forget the man command.

man <command>

Will give you a man page for the command.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 1

Expert Comment

by:filippos
ID: 11979308
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
0
 
LVL 1

Expert Comment

by:filippos
ID: 11979312
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
0
 
LVL 5

Expert Comment

by:ITcrow
ID: 11983270

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!

-------------------------------8<-------------------------------------
#! /bin/csh -f

echo Hi !
echo
echo This introduction to UNIX stuff isn’t bad.
echo
echo I’ve enjoyed learning UNIX!

------------------------------->8-------------------------------------

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!”
-------------------------------8<-------------------------------------
#! /bin/csh -f

echo -n Hi !
echo This introduction to UNIX stuff isn’t bad.
echo
echo I’ve enjoyed learning UNIX!
------------------------------->8-------------------------------------

b) How can I add a line at the end that gives today’s date.
-------------------------------8<-------------------------------------
#! /bin/csh -f

echo -n Hi !
echo This introduction to UNIX stuff isn’t bad.
echo
echo I’ve enjoyed learning UNIX! `date`
------------------------------->8-------------------------------------

0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 12244022
PAQed - no points refunded (of 500)

Computer101
E-E Admin
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses
Course of the Month14 days, 7 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question