On 10/24/2012 12:48 PM, Joseph Acquisto wrote:
How can I trap/redirect the -D output? In entirety? I use putty to
access the box and cannot sroll back all the way to the beginning of
output. Perhaps there is a secret to that, as well. joe a.
This is a bit basic but I would recommend you learn more about the pipe
command and input/output redirection in Unix.
Your mileage may vary but here's some real-world examples to get you
started.
view a file:
cat /tmp/file
view a file with pagination:
cat /tmp/file | more
redirect standard out to a file:
cat /tmp/file > /tmp/file.bak
redirect standard out and standard error:
spamassassin -t /tmp/mboxfile -D 2>&1
redirect standard out and standard error to a file:
spamassassin -t /tmp/mboxfile -D 2>&1 > /tmp/file.out
output to a file and view at the same time:
spamassassin -t /tmp/mboxfile -D 2>&1 | tee /tmp/file.out
You can also redirect input.
Send a blank email redirecting /dev/null as the input:
mail -s 'test' kmcgr...@pccc.com < /dev/null
With unix, you can do a lot of crazy things with pipes and I use it a
lot for general tasks.
For example, want the largest file in a dir?
ls -1s /var/spool/mail/ | sort -n
Want to get all the sub routines defined in a perl library listed
alphabetically?
grep "sub " Library_hsubox.pm | grep { | awk '{print $2}' | sort
Have a list of stuff with duplicates? Pipe through sort then uniq:
(Couldn't think of a good example without a dataset that has lots of
duplicates. But for example, you could grep an access log, use awk to
grab the IP, sort by IP and then use uniq to get a list of unique ip
addresses).
Here's a good free book: http://linux.101hacks.com/toc/
Regards
KAM