Web Hosting Talk







View Full Version : cat and grep


StarWeb
01-24-2006, 07:52 PM
Ok, why does:

cat /usr/local/apache/conf/httpd.conf | grep $ARG1 -B 13 -A 10 > /tmp/httpd.conf

Return the 27 lines of httpd.conf that i want to delete, but:

cat /usr/local/apache/conf/httpd.conf | grep -v $ARG1 -B 13 -A 10 > /tmp/httpd.conf

Return the whole httpd.conf, line by line and does not remove the 27 lines?

Thanks,

bear
01-24-2006, 08:38 PM
-v Displays all lines not matching the specified pattern.
Maybe that's why?

StarWeb
01-24-2006, 08:47 PM
I am trying to remove the 27 lines and save the rest to a file.

Thanks,

innova
01-24-2006, 09:35 PM
why would you ever do this:

cat file | grep

Its silly..

how about:

grep -options file

StarWeb
01-24-2006, 09:52 PM
hmm, it is a 2.5 MB httpd.conf file and i need to remove 800+ vitural hosts via a username list.

I tried grep -options file and it hung.

This is what I am trying:


#!/bin/sh -x
for ARG1 in `cat /tmp/users.txt`; do
#echo $ARG1
cat /usr/local/apache/conf/httpd.conf | grep -v $ARG1 -B 13 -A 10 > /tmp/httpd.conf
exit
#cp /tmp/httpd.conf /usr/local/apache/conf/httpd.conf
done