LinuxQuestions.org
Help answer threads with 0 replies.
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 02-29-2012, 01:45 PM   #1
moony10
LQ Newbie
 
Registered: Feb 2012
Posts: 5

Rep: Reputation: Disabled
System Date Command Usage


Newbie here and I'm puzzled. I'm sure someone more experienced can help me figure this out.

why did I get the system date command instead of the script?

$ whereis date
date: /bin/date ...
$ echo $PATH
.:/usr/local/bin:/usr/bin:/bin
$ cat > date //; assuming the creation of new data file current working directory. File was not there to begin with;//
echo "This is my own version of date."
<CTRL-D>
$ date
Fri May 22 11:45:49 PDT 2009
 
Old 02-29-2012, 01:54 PM   #2
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
Quote:
$ cat > date //; assuming the creation of new data file current working directory. File was not there to begin with;//
echo "This is my own version of date."
<CTRL-D>
$ date
A few things:
1. The bash comment character is '#' -- not '//'. That likely doesn't affect the root issue, but just to be clear that you aren't mixing-and-matching different language syntax...

2. You never made your custom date script executable. Unless the script is executable, it doesn't matter whether the file is in your PATH or not.
Code:
chmod u+x name_of_file
3. The proper way to create a script is to start the script with a "shebang" line that tells the system what program is needed to interpret the commands in the file. It looks like you're trying to use bash. So:
Code:
$ cat > date
#!/bin/bash

echo "This is my own version of date."
<CTRL-D>
 
Old 02-29-2012, 02:06 PM   #3
moony10
LQ Newbie
 
Registered: Feb 2012
Posts: 5

Original Poster
Rep: Reputation: Disabled
Hello Dark Helmet

Thank You. That makes sense. And the //; (info in between) was just my way of adding a comment to the question and has no impact to the Linux command being ran. Sorry for that confusion. But your response makes sense and I see now why it wasn't displaying correctly.

Thanks again.
 
  


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
how can i move to previous system date using command line karan_bagaria Linux - Newbie 5 09-22-2010 05:01 PM
History command with system date shipon_97 Linux - Newbie 5 12-26-2009 03:41 AM
Setting system date and time affecting the clock and date on BIOS satimis Ubuntu 7 09-21-2007 09:02 AM
command for checking system resource usage? yeahoo7 Linux - Networking 3 06-12-2003 12:31 AM
lastlog date does not match system date? jcmj Linux - Networking 6 10-22-2002 01:09 PM


All times are GMT -5. The time now is 06:42 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