[GRLUG] Bash split question, ..
Don Ellis
don.ellis at gmail.com
Thu May 26 15:55:13 EDT 2011
On Thu, May 26, 2011 at 2:54 PM, Don Ellis <don.ellis at gmail.com> wrote:
> On Thu, May 26, 2011 at 2:52 PM, Don Ellis <don.ellis at gmail.com> wrote:
>> 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.
>
> Sorry -- I forgot you said "in perl, split" -- the "cut" command in
> bash can be similar to the "split" command in perl.
And reading the original again, I was really right the first time ;-)
--Don Ellis
--
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