LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 09-16-2007, 11:58 AM   #1
jerf
Member
 
Registered: Sep 2007
Posts: 46

Rep: Reputation: 15
basic bashrc question


Hi folks,

first time poster, long time reader.

im goofing around with the shell/scripting tutorials from linuxcommand.org and im getting a syntax error that i dont understand. was hoping for some insight.

the lesson:

Aliases are good for very simple commands, but if you want to create something more complex, you should try shell functions. Shell functions can be thought of as "scripts within scripts" or little sub-scripts. Let's try one. Open .bashrc with your text editor again and replace the alias for "today" with the following:


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

the file:

# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

# User specific aliases and functions

alias l='ls -l'

function today {
> echo "Today's date is:"
> date +"%A, %B %-d, %Y"
> }
~
~
~
~
~
~
~
~
".bashrc" 15L, 214C 15,1 All



the error:

bash: /home/people/.bashrc: line 16: syntax error: unexpected end of file



any thoughts?

thanks,
jerf
 
Old 09-16-2007, 03:20 PM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,570

Rep: Reputation: 171Reputation: 171
Do the extra characters (> and ~s) appear in your source file? It should look this way:
Code:
# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

# User specific aliases and functions

alias l='ls -l'

function today {
  echo "Today's date is:"
  date +"%A, %B %-d, %Y"
}
 
Old 09-17-2007, 03:50 AM   #3
jerf
Member
 
Registered: Sep 2007
Posts: 46

Original Poster
Rep: Reputation: 15
yeah the tildas and greaterthan's are in the file. ill try removing them. thanks.
 
Old 09-17-2007, 03:59 AM   #4
jerf
Member
 
Registered: Sep 2007
Posts: 46

Original Poster
Rep: Reputation: 15
not sure why those symbols were in there to begin with, but removing them solved the issue. thanks a bunch.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
newbie question : how to edit bashrc pingu99 Linux - Software 5 10-26-2010 07:22 PM
Setting path: /etc/profile, /etc/bashrc or ~/.bashrc Swakoo Linux - General 1 08-07-2007 10:59 PM
basic .bashrc question TheGNUbie Linux - Newbie 1 03-08-2007 11:05 AM
.bashrc question aizkorri Programming 6 08-14-2002 06:41 AM
Question on .bashrc Fluke Linux - Newbie 2 06-29-2002 01:40 PM


All times are GMT -5. The time now is 03:00 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration