LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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 07-23-2011, 01:30 AM   #1
kenny53067
Member
 
Registered: Jul 2011
Location: Rio Grande City, Texas
Posts: 54

Rep: Reputation: Disabled
Unhappy Need help with homework!!


$ whereis date
/bin/date
$ echo $PATH
.:/usr/local/bin:/usr/bin:/bin
$ cat > date
echo "This is my own version of date."
$ date
Tue May 24 11:45:49 PDT 2005

The question asks what is the unexpected result for this script. When I input this script, I can't get past $ cat > date. Can someone tell me why and steer me in the right direction on answering this question right.
 
Old 07-23-2011, 01:43 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
It is happening because cat, when called without a file name, reads from stdin. When it hangs, type in something and press Enter; whatever you typed will be written to file "date".

EDIT: sorry -- that should have been Ctrl+D to end the input, not Enter. Thanks to subsequent posters for pointing it out.

Last edited by catkin; 07-23-2011 at 03:24 AM.
 
Old 07-23-2011, 02:15 AM   #3
kenny53067
Member
 
Registered: Jul 2011
Location: Rio Grande City, Texas
Posts: 54

Original Poster
Rep: Reputation: Disabled
how do I get the $ back so I can type the last command or can I ?
 
Old 07-23-2011, 02:17 AM   #4
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Quote:
Originally Posted by kenny53067 View Post
how do I get the $ back so I can type the last command or can I ?
Ctrl-D will "quit" cat.
 
1 members found this post helpful.
Old 07-23-2011, 02:28 AM   #5
kenny53067
Member
 
Registered: Jul 2011
Location: Rio Grande City, Texas
Posts: 54

Original Poster
Rep: Reputation: Disabled
Thumbs up

Thank you Nylex
 
Old 07-23-2011, 02:33 AM   #6
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
No problem. Ctrl-D sends "end of file" to the process (i.e. telling it that the end of the input has been reached), so it's a general keystroke, rather than being specific to cat.
 
1 members found this post helpful.
  


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
College Homework Help, Statistics Homework Help, Finance Homework Help, Accounting marklaren Linux - Software 1 12-25-2009 07:14 AM


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