LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Pipe Apropos to Newfile (https://www.linuxquestions.org/questions/linux-newbie-8/pipe-apropos-to-newfile-927937/)

Pl3th0r4x 02-06-2012 01:54 PM

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.:doh:

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?

TobiSGD 02-06-2012 02:09 PM

If you want to put the output of a command into a file you have to use redirection.

Pl3th0r4x 02-06-2012 02:14 PM

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.

TobiSGD 02-06-2012 02:23 PM

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.

alan_ri 02-06-2012 02:30 PM

Code:

apropos calendar > Newfile
Done.

Pl3th0r4x 02-06-2012 02:43 PM

Quote:

Originally Posted by alan_ri (Post 4595333)
Code:

apropos calendar > Newfile
Done.

Jesus I cant believe I never actually tried that, but I actually didn't-- and it worked. :o

Also, thanks Tobi as well.

XavierP 02-11-2012 01:18 PM

Moved: This thread is more suitable in Linux-Newbie and has been moved accordingly to help your thread/question get the exposure it deserves.

chrism01 02-12-2012 06:13 PM

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/

Fred Caro 02-12-2012 08:10 PM

redirection (| > >>)
 
What course are you on and what does it cost? There are many and many take the micky on cost.

Fred.


All times are GMT -5. The time now is 09:53 AM.