LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   SHELL scripting/ shell functions (https://www.linuxquestions.org/questions/linux-newbie-8/shell-scripting-shell-functions-609193/)

mayaabboud 12-26-2007 07:41 AM

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

pwc101 12-26-2007 07:53 AM

Quote:

Originally Posted by mayaabboud (Post 3001833)
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!

mayaabboud 12-26-2007 07:58 AM

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]$

sycamorex 12-26-2007 08:06 AM

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

mayaabboud 12-26-2007 08:10 AM

shell scripting
 
try saving it in a file,

can u show how to do that?

thx alot for ur help :)

mayaabboud 12-26-2007 08:12 AM

oh yes i see
thx

mayaabboud 12-26-2007 08:18 AM

thanks a million

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

maya


All times are GMT -5. The time now is 03:59 PM.