| PLEX86 | ||
|
Howto implement AND in grepNo need for cat: DVD for Archiving and Backup I tried using DVD-R last year to make backups, but without much success. I posted here for help, and here is a... grep str1 file.txt grep str2 grep str3... Either of the two scripts posted (by Michael Heiming and Peter Breuer) should give you a solution, but Michael's is not complete for your task. I found this mgrep script I wrote a couple of years ago which does what you want. I don't think I've used it since; I probably wrote it in response to a similar question posted at the time. It expands on Michael's recommendation. DVD for Archiving and Backup DVD-R doesn't have the shelflife needed for longterm archiving, so NO. (same for DVD+R, CD-R) However I- and... This works best with mawk, as it's faster than gawk. # Mon Jan 13 13:28:19 EST 2003 # NAME: mgrep # USAGE: mgrep -e PAT1 -e PAT2 -e.... FILE ... # Copyright 2003, Chris F.A. Johnson # Released under the terms of the GNU General Public License while getopts e: opt do case "$opt" in e) cmd="${cmd:+$cmd && }-$OPTARG-" ;; esac done shift $(( $OPTIND - 1 )) #################################################### Peter's solution is a neat recursive function, but it requires cat and multiple calls to grep (as opposed to a single call to awk in the above script) making it slower as the number of patterns increases (but the difference decreases as file size increases). Problems with Tomcat 5 and JVM SUN 1.5.0 Update 4 on Fedora 4 Problems with Tomcat 5 and JVM SUN 1.5.0 Update 4 on Fedora 4 Hi all, I`m having problems with Tomcat 5 startup on FC4. The two main error messages are:usr... For general use, patterns and file names need to be separated, and files catted, before the function can be called. Here is a more general script using Peter's function, made more portable by avoiding "local", and enhancing performance by using -n rather then -le in the test, and grep rather than cat as the first command in the pipeline: ## Usage is the same as the above script mrgrep() { if -n "$*" ; then cat else mrgrepstr="$1" shift fi } while getopts e: opt do case "$opt" in e) cmd="$cmd '$OPTARG'" ;; esac done
-- ================================================================== Author: Shell Scripting Recipes: A Problem-Solution Approach
|
||||
Problems with Tomcat 5 and JVM SUN 1.5.0 Update 4 on Fedora 4 Linux groups from Newsgroups The #1 Usenet Provider on the Internet
|
||||