LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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-06-2012, 01:54 PM   #1
Pl3th0r4x
Member
 
Registered: Dec 2011
Location: Land of Derk
Distribution: Derka
Posts: 71

Rep: Reputation: 0
Pipe Apropos to Newfile


K, I am stuck on my teachers 2nd question. I have 10 tabs open and none of them are helping get the answer.

He wants me to run the command

$ apropos calendar

here is the output

Code:
Curses::Widgets::Calendar (3pm) - Calendar Widgets
cal (1)              - displays a calendar and the date of Easter
calendar (1)         - reminder service
Date::Calc (3pm)     - Gregorian calendar date calculations
Date::Calendar (3pm) - Calendar objects for different holiday schemes
Date::Calendar::Profiles (3pm) - Some sample profiles for Date::Calendar and Date::Calendar::Year
Date::Calendar::Year (3pm) - Implements embedded "year" objects for Date::Calendar
evolution (1)        - groupware suite for GNOME containing e-mail, calendar, addressbook, to-do ...
ncal (1)             - displays a calendar and the date of Easter
He then wants me to put this output into a newfile

I created the newfile folder, but every command I have tried is just renaming the folder and not actually putting the contents of calendar into the newfile.

I am using

cat
ls
touch
mv

but none of these are actually taking the output of calendar and inputting them into newfile.

He wants us to use the info and man pages to figure out to do it, but they aren't helping, or I do not see where the answer is. Can anyone give me better direction before I just email him?
 
Old 02-06-2012, 02:09 PM   #2
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
If you want to put the output of a command into a file you have to use redirection.
 
Old 02-06-2012, 02:14 PM   #3
Pl3th0r4x
Member
 
Registered: Dec 2011
Location: Land of Derk
Distribution: Derka
Posts: 71

Original Poster
Rep: Reputation: 0
Yeah, thats actually in the question:

Quote:
Use the apropos command to get a list of utilities related to "calendar" (as a keyword) and redirect the output to another file. Make a note of the file name. What was the command?
What I dont know is how. Do you mean with a ">" character? Such as cat calendar > newfile

or replace cat with mv, cp, touch, etc? Because those arent working and I literally have about 9 tabs open and I cant seem to get it.
 
Old 02-06-2012, 02:23 PM   #4
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
You want to redirect the output of the command
Code:
apropros calendar
to a file, so why would you try redirect the output of a cat, mv, cp, touch, ... command?
Here seems to be a misunderstanding. To create a new file (the file doesn't have to exist for a redirection) and put the content of stdout into it all you need is the >-sign.
For example:
Code:
ls > test
will launch the command ls (which prints it output to stdout) and then redirect stdout to a file called test. This file is created if it doesn't exist, otherwise it will be overwritten. No cat, mv, touch, ... involved.
 
Old 02-06-2012, 02:30 PM   #5
alan_ri
Senior Member
 
Registered: Dec 2007
Location: Croatia
Distribution: Debian GNU/Linux
Posts: 1,733
Blog Entries: 5

Rep: Reputation: 127Reputation: 127
Code:
apropos calendar > Newfile
Done.
 
Old 02-06-2012, 02:43 PM   #6
Pl3th0r4x
Member
 
Registered: Dec 2011
Location: Land of Derk
Distribution: Derka
Posts: 71

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by alan_ri View Post
Code:
apropos calendar > Newfile
Done.
Jesus I cant believe I never actually tried that, but I actually didn't-- and it worked.

Also, thanks Tobi as well.
 
Old 02-11-2012, 01:18 PM   #7
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Debian Testing
Posts: 19,192
Blog Entries: 4

Rep: Reputation: 475Reputation: 475Reputation: 475Reputation: 475Reputation: 475
Moved: This thread is more suitable in Linux-Newbie and has been moved accordingly to help your thread/question get the exposure it deserves.
 
Old 02-12-2012, 06:13 PM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,369

Rep: Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753
You may find these worth bookmarking
http://rute.2038bug.com/index.html.gz
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
http://www.tldp.org/LDP/abs/html/
 
Old 02-12-2012, 08:10 PM   #9
Fred Caro
Senior Member
 
Registered: May 2007
Posts: 1,007

Rep: Reputation: 167Reputation: 167
redirection (| > >>)

What course are you on and what does it cost? There are many and many take the micky on cost.

Fred.
 
  


Reply



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
rename oldfile to newfile only if newfile does not exist nagendrar Linux - Newbie 1 09-09-2009 06:27 AM
cat onelinefile.txt >> newfile.txt; cat twofile.txt >> newfile.txt keep newline? tmcguinness Programming 4 02-12-2009 06:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:47 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
Open Source Consulting | Domain Registration