LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-26-2007, 07:41 AM   #1
mayaabboud
Member
 
Registered: Oct 2007
Posts: 53

Rep: Reputation: 15
Unhappy SHELL scripting/ shell functions


hellow,

does anyone know a good website for scripting-newbies ? I found a tutorial on lingucommand.org, but there seems to be syntax-errors!
so can anyone help me in writing shell functions?

thanks alot in advance

maya
 
Old 12-26-2007, 07:53 AM   #2
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
Quote:
Originally Posted by mayaabboud View Post
I found a tutorial on lingucommand.org, but there seems to be syntax-errors!
Do you mean linuxcommand.org?

Which commands were giving you syntax errors? I'd be quite surprised if that website had syntax errors in its examples!
 
Old 12-26-2007, 07:58 AM   #3
mayaabboud
Member
 
Registered: Oct 2007
Posts: 53

Original Poster
Rep: Reputation: 15
shell scripting

yes , linuxcommand.org

well, i tried the same program, as written on my computer and it didnt give the results they said it would, here s the example given, ofcourse i saved it in a file rather than directly on the prompt !

[me@linuxbox me]$ function today {
> echo "Today's date is:"
> date +"%A, %B %-d, %Y"
> }
[me@linuxbox me]$
 
Old 12-26-2007, 08:06 AM   #4
sycamorex
LQ Veteran
 
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,836
Blog Entries: 1

Rep: Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251
there doesn't seem to be any problem with the syntax of that function

Quote:
sycamorex@debian205:~$ function today {
> echo "Today's date is:"
> date +"%A, %B %-d, %Y"
> }
sycamorex@debian205:~$ today
Today's date is:
Wednesday, December 26, 2007
sycamorex@debian205:~$
When you create a file:
$ emacs today_date

Quote:
#!/bin/bash

function today {
echo "Today's date is:"
date +"%A, %B %-d, %Y"
}

today
exit 0
$ chmod +x today_date
$ ./today_date
Today's date is:
Wednesday, December 26, 2007

Last edited by sycamorex; 12-26-2007 at 08:10 AM.
 
Old 12-26-2007, 08:10 AM   #5
mayaabboud
Member
 
Registered: Oct 2007
Posts: 53

Original Poster
Rep: Reputation: 15
shell scripting

try saving it in a file,

can u show how to do that?

thx alot for ur help
 
Old 12-26-2007, 08:12 AM   #6
mayaabboud
Member
 
Registered: Oct 2007
Posts: 53

Original Poster
Rep: Reputation: 15
oh yes i see
thx
 
Old 12-26-2007, 08:18 AM   #7
mayaabboud
Member
 
Registered: Oct 2007
Posts: 53

Original Poster
Rep: Reputation: 15
thanks a million

now it worked, guess it was the last two lines that were missing !

maya
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell Scripting: Getting a pid and killing it via a shell script topcat Programming 15 10-28-2007 02:14 AM
teaching shell scripting: cool scripting examples? fax8 Linux - General 1 04-20-2006 04:29 AM
shell interface vs shell scripting? I'm confused jcchenz Linux - Software 1 10-26-2005 03:32 PM
shell script functions iNET_boss Linux - General 1 08-10-2005 04:41 PM
Comparison of shell functions and aliases? slakmagik Programming 3 02-07-2004 05:12 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration