LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 03-12-2011, 02:43 AM   #1
coldfire007
LQ Newbie
 
Registered: Mar 2011
Posts: 4

Rep: Reputation: 0
how to execute this on the shell


ill have this question on the test maybe :

In dir00 directory create files year01.txt, year02, ...year05.txt with January calendar for 2001-2005 years in it.


-i'm lost. i execute this : cat | cal 01 2001 > year01.txt
but i dont know how to do it recursivly. thank u for helping me
 
Old 03-12-2011, 02:46 AM   #2
corp769
LQ Guru
 
Registered: Apr 2005
Posts: 5,817

Rep: Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002
Hello and welcome to LQ!

Quote:
ill have this question on the test maybe
Does this mean this is on a test you are taking, or homework? If so, no one will help you. You can ask for general advise, but we will not do homework or take tests for you, plain and simple.

As far as your question, what are you trying to perform recursively?
 
Old 03-12-2011, 02:54 AM   #3
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
This is not recursion. What do you need is a loop over years from 2001 to 2005. Try to write it down so we can take a look if something goes wrong.
 
Old 03-12-2011, 03:28 AM   #4
ButterflyMelissa
Senior Member
 
Registered: Nov 2007
Location: Somewhere on my hard drive...
Distribution: Manjaro
Posts: 2,686
Blog Entries: 23

Rep: Reputation: 398Reputation: 398Reputation: 398Reputation: 398
You'll have to keep leap years in account, but all in all, you need a loop to do this, I fully concur with colucix. Also, your program must have a) execute rights and b) write permission to the folder in question.

If it is only january, the thing is simple (I'm at a loss to the purpose: a calendar with ONLY january, but, this is not my homework) you need two nested loops.

Hmm, do I smell the faint oudor of ... homework?
I have to concur with corp769 though, please dont let US do YOUR homework. Homework has been wrongly translated from the "ancient texts" where it meant "an opportunity to learn and grow"...

Good luck

Thor

Last edited by ButterflyMelissa; 03-12-2011 at 03:30 AM.
 
Old 03-12-2011, 03:57 AM   #5
coldfire007
LQ Newbie
 
Registered: Mar 2011
Posts: 4

Original Poster
Rep: Reputation: 0
i got it as soon as i post it, thank you guys haha im excited with linux , i mean i'm in love with linux hehe but i knew it my question was a bit weird cause im a newbie.

Last edited by coldfire007; 03-13-2011 at 12:36 AM.
 
Old 03-12-2011, 05:12 AM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530
Quote:
Originally Posted by coldfire007 View Post
i got it as soon as i post it
Then please post your solution (reciprocity and all that).


Quote:
Originally Posted by coldfire007 View Post
i knew it my question was a bit weird cause im a newbie.
No, it's not because you're a new Linux user but because some members sensed this might have been homework.


Quote:
Originally Posted by coldfire007 View Post
now
Now, since you have conveniently neither confirmed or denied it is homework I would like to point you to LQ Rule #11: "Do not expect LQ members to do your homework - you will learn much more by doing it yourself".
There are different ways to do what you want (cat, history, cp, etc, etc) but maybe instead of giving you a fish we should give you a fishing rod:
http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
http://www.tldp.org/LDP/Bash-Beginne...tml/index.html
http://www.tldp.org/LDP/abs/html/
 
1 members found this post helpful.
Old 03-12-2011, 05:16 AM   #7
ButterflyMelissa
Senior Member
 
Registered: Nov 2007
Location: Somewhere on my hard drive...
Distribution: Manjaro
Posts: 2,686
Blog Entries: 23

Rep: Reputation: 398Reputation: 398Reputation: 398Reputation: 398
Quote:
No, it's not because you're a new Linux user but because some members sensed this might have been homework.
Well...I should apologise!

Sorry, dude...glad you found the solution, please enlighten the community and share it.

Thor
 
Old 03-12-2011, 03:22 PM   #8
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530
Quote:
Originally Posted by linusr@flanders View Post
Well...I should apologise!
Uh. I think that's a misunderstanding? No need to.
 
1 members found this post helpful.
Old 03-12-2011, 06:06 PM   #9
ButterflyMelissa
Senior Member
 
Registered: Nov 2007
Location: Somewhere on my hard drive...
Distribution: Manjaro
Posts: 2,686
Blog Entries: 23

Rep: Reputation: 398Reputation: 398Reputation: 398Reputation: 398
Quote:
Uh. I think that's a misunderstanding? No need to.
Thanks, you brightened my day I felt I had to apologise for assuming I was helping someone out with his homework while he was simply asking for a helping hand...case of jumping tru the wrong loop of my part, I thought.
 
Old 03-12-2011, 07:14 PM   #10
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530
NP. Contrary to what some members have come to believe (who might have forgotten they once were new Linux users too) is that LQ is a knowledge base for all things Linux. Anyone asking a question, as long as it does not violate any LQ Rules, deserves a reply or answer that contains more than solely "go google for it", "use distribution version X" or "here's a catb link on how to ask questions".

After all we're Linuxquestions.org: you've got the question, we've got the answer.
 
3 members found this post helpful.
Old 03-13-2011, 12:34 AM   #11
coldfire007
LQ Newbie
 
Registered: Mar 2011
Posts: 4

Original Poster
Rep: Reputation: 0
well for the answer i did it my way, it was the same i've montioned on the begining i wasn't sure but it still fine # cat | cal 01 2001 > year01.txt ; cat | cal 01 2002 > year02.txt ; ........ 'till: cat | cal 01 2005 > year05.txt [and it wasn't home work ] and for "loop" command i didn't study it yet.
 
Old 03-13-2011, 12:45 AM   #12
EDDY1
LQ Addict
 
Registered: Mar 2010
Location: Oakland,Ca
Distribution: wins7, Debian wheezy
Posts: 6,838

Rep: Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649
Quote:
[and it wasn't home work ]
Quote:
ill have this question on the test maybe :
Close
The maybe makes it anticipatory, but, not homework.

Last edited by EDDY1; 03-13-2011 at 12:46 AM.
 
Old 03-13-2011, 01:30 AM   #13
coldfire007
LQ Newbie
 
Registered: Mar 2011
Posts: 4

Original Poster
Rep: Reputation: 0
oh many thanks to unSpawn especially for the 3 links ! it will be so useful for me
 
  


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 to execute shell through C program pawarsac Linux - Software 2 07-22-2006 05:23 AM
Shell won't execute commands.... frank320 Red Hat 6 03-17-2006 12:12 PM
cannot execute 'cd /' shell command from PL/SQL.... samyakm Linux - Newbie 1 01-03-2005 11:10 AM
shell script won't execute brandnewbie Linux - Newbie 7 08-10-2004 02:30 PM
shell script how to execute x2000koh Programming 6 07-29-2003 05:20 PM


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