Shell question

Posted by Ithildin on Thu 17 Mar 2005 12:10 AM — 5 posts, 21,374 views.

USA #0
I'm wondering if there is a command in unix that lets you take information from one file and put it into another.

IE: I'm logging someone and want to put all their logged commands into another file so I don't have to wade through the other logged commands. Is there a command in shell that can do this?

sample:

send *logged commands* *name* *file1* to *file2*
Australia #1
i think you should be able to grep the file and pipe the output into another file, as for correct syntax i dont remember, tho i remember doing this sort of thing in my old xenox classes at TAFE back in the mid 90's heh.
Amended on Thu 17 Mar 2005 02:42 AM by Robert Powell
USA #2
Yea, I have been looking at grep alot, but how do i pipe it into another file? Guess I can go try to look it up over internet.

_____________________________________-

I didn't find anything. I found that | is the pipe function.
I tried
[code]
grep 'name' *.log -ni | name.txt
[/code]
and it said name.txt not good.
Amended on Thu 17 Mar 2005 10:31 PM by Ithildin
Australia #3
It has been a long time since i did NUX command line, i think you need to use a redirect not a pipe > then filename, but i could be wrong.

So grep string log.file > out.file will work, now what you could do if you want to be real tricky is pipe the output of the first grep into a second grep and then to a file, so you can narrow the search down to what your looking for.

grep str1 log.file | grep str2 > out.file.

Hope that helps, its been a while since i did any of this stuff.
Amended on Fri 18 Mar 2005 12:14 AM by Robert Powell
USA #4
worked. thanks!