Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

UNIX Shell

Posted on 2004-08-27
8
Medium Priority
?
512 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
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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
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.:
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

636 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