?
Solved

UNIX Shell

Posted on 2004-08-27
8
Medium Priority
?
510 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 
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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
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…
Suggested Courses
Course of the Month12 days, 11 hours left to enroll

777 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