Solved

UNIX Shell

Posted on 2004-08-27
8
500 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
8 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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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 …
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
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.

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now