Page MenuHomePhabricator
Paste P6875

what a beautiful baby...
ActivePublic

Authored by dduvall on Mar 21 2018, 5:59 PM.
Tags
None
Referenced Files
F15948893: what a beautiful baby...
Mar 21 2018, 6:00 PM
F15948889: what a beautiful baby...
Mar 21 2018, 5:59 PM
Subscribers
Tokens
"Love" token, awarded by hashar."The World Burns" token, awarded by zeljkofilipin.
vm = `VBoxManage list vms`.each_line.map do |l|
l.split(' ').first.split('"')[1]
end.find do |vm|
name.casecmp(vm) == 0
end

Event Timeline

dduvall changed the title of this paste from untitled to what a beautiful baby....
dduvall updated the paste's language from autodetect to autodetect.
dduvall updated the paste's language from autodetect to ruby.Mar 21 2018, 6:00 PM
dduvall edited the content of this paste. (Show Details)
[x for x in
    map(
        lambda x: x.split(' ')[0].split('"')[1],
        subprocess.check_output('VBoxManage list vms', shell=True).splitlines()
    )
    if x.lower() == name.lower()
]
vm = `VBoxManage list vms`.each_line.map { l.split(' ').first.split('"')[1] }.find { |vm| name.casecmp(vm) == 0 }
while read vm; do
    vm="${vm% *}"    # Split first space
    vm="${vm#\"*}"   # Remove beginning quote
    vm="${vm%\"*}"   # Remove trailing quote
    [[ "$vm" =~ "$NAME" ]] && printf '%s\n' "$vm"
done < <(VBoxManage list vms)

The power of bash:

VBoxManage list vms | grep -i "$vm"
In P6875#39128, @hashar wrote:

The power of bash:

VBoxManage list vms | grep -i "$vm"

daaaammnnn

foreach my $vm (map { s/"(.*)" .*/$1/; $_ }  split("\n", `VBoxManage list vms`)) { print "$vm\n" if $vm =~ /^$name.*/; }
foreach my $vm (map { s/"(.*)" .*/$1/; $_ }  split("\n", `VBoxManage list vms`)) { print "$vm\n" if $vm =~ /^$name.*/; }

Oh dear.