[GRLUG] Bash split question, ..
Don Ellis
don.ellis at gmail.com
Thu May 26 15:52:35 EDT 2011
On Thu, May 26, 2011 at 2:35 PM, L. V. Lammert <lvl at omnitec.net> wrote:
> I'm thinking there must be a simple way to do this in bash, ..
>
> Starting with:
>
> mailq | grep MAILER | xargs postsuper -d ___________--
>
> In perl it might be something like split (' ',$1), but it seems much simpler
> to use the built-in bash split (and more efficient since we would be doing
> thousands a night). Unfortunately, I cannot grok any docs that make any
> sense <g>!
I think you want cut, not split!
Not sure how to deal with the asterisk you mentioned.
Also, notice that Bash 3 (echo $BASH_VERSION) has regexes:
= = = = = = = = = = = = =
#!/bin/bash
variable="This is a fine mess."
echo "$variable"
# Regex matching with =~ operator within [[ double brackets ]].
if [[ "$variable" =~ T.........fin*es* ]]
# NOTE: As of version 3.2 of Bash, expression to match no longer quoted.
then
echo "match found"
# match found
fi
= = = = = = = = = = = = =
(Got that from Advanced Bash Scripting, a PDF) There are some other
goodies there as well.
--Don
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
More information about the grlug
mailing list