Last active
July 21, 2021 13:55
-
-
Save smonff/bb7e7bab4433fd70d8679357c3692c13 to your computer and use it in GitHub Desktop.
/proc/mounts to JSON with perlcore only
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use diagnostics; | |
use JSON::PP; | |
my @only = qw(ext4); | |
my @mounts = (); | |
for (`cat /proc/mounts`) { | |
my ($fsname, $fstype, $fsmodes) = m/\S+ (\S+) (\S+) (\S+)/; | |
next unless grep { $fstype =~ $_ } @only; | |
push @mounts, { | |
'#FSNAME' => $fsname, | |
'#FSTYPE' => $fstype, | |
'#FSMODES' => $fsmodes, | |
}; | |
} | |
print JSON::PP->new->pretty->canonical->encode({ mounts => \@mounts }); | |
Author
smonff
commented
Jul 21, 2021
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment