I'm relatively novice in Unix Shell Scripting.
How can I run the (following) multiple UNIX commands (put into a script, say "discover.sh", using my_log.txt input-file just once? Eventually, I would like to create an alias [alias discover1='~/discover.sh'] in my .bashrc.
Like:
$ discover1 my_log.txt
Current script:
/bin/egrep 'Version:|Online \(warning\)|Failed \(offline\)' my_log.txt;
/bin/grep -A7 "syscontrol realmmgr" my_log.txt;
/bin/grep -C2 BIOS my_log.txt;
$HOME/bindirectory, which should be on your$PATH? There probably are ways to cat the file just once, especially inbash. I'm not sure whether they're worth using. For example:cat my_log.txt | tee >(/bin/egrep 'Version...') >(/bin/grep -A7 "...") | /bin/grep -C BIOS. This loses control over the sequencing of the output (you could get partial lines from different processes). If you really want to scan the file just once, I suggest using Perl do the searches all at once. Not quite trivial, but pretty easy.