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
Solved

UNIX Shell

Posted on 2004-08-27
8
504 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Suggested Solutions

Title # Comments Views Activity
cvstrac compile - ld: fatal: Symbol referencing errors. collect2: ld returned 1 exit status 16 127
Shell script errors 10 141
Unix/bash: scripted arithmetic 13 101
UNIX SCP 5 83
Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
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 several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

828 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