Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
deleted 21 characters in body
Source Link
MestreLion
  • 1.6k
  • 17
  • 22

I feel your pain... I also love the sudo-less power of udisksctl, I use UDisks2 in several snippets and projectsprojects, and I also hate how "machine-unfriendly" its output is.

That said, one approach I'm leaning towards to is not to parse the output of udisksctl mount,loop-*,..., use it for actions only, and leave parsing to udisksctl info, udevadm or even lsblk -lnpb (which can even have JSON output if you're willing to use jq!).

If you do parse udisksctl, at least prepend it with LC_ALL=C to avoid localized messages by using the fixed C "virtual" locale, so you at least guarantee the strings matched won't change per user environment.

Examples:

  • Listing the (writable) partitions with a known filesystem of a drive device (if any):
lsblk "$device" -lnpb --output NAME,RO,FSTYPE | awk '$2 == 0 && $3 {print $1}'
  • Getting the mountpoint of one such partition above after mounting:
LC_ALL=C udisksctl info -b "$partition" | grep -Po '^ *MountPoints: *\K.*'

No more grepping human-intended messages!

(or, better yet, make your voice heard in this still open 2017 request for a script-friendly interface)

I feel your pain... I also love the sudo-less power of udisksctl, I use UDisks2 in several snippets and projects, and I also hate how "machine-unfriendly" its output is.

That said, one approach I'm leaning towards to is not to parse the output of udisksctl mount,loop-*,..., use it for actions only, and leave parsing to udisksctl info, udevadm or even lsblk -lnpb (which can even have JSON output if you're willing to use jq!).

If you do parse udisksctl, at least prepend it with LC_ALL=C to avoid localized messages by using the fixed C "virtual" locale, so you at least guarantee the strings matched won't change per user environment.

Examples:

  • Listing the (writable) partitions with a known filesystem of a drive device (if any):
lsblk "$device" -lnpb --output NAME,RO,FSTYPE | awk '$2 == 0 && $3 {print $1}'
  • Getting the mountpoint of one such partition above after mounting:
LC_ALL=C udisksctl info -b "$partition" | grep -Po '^ *MountPoints: *\K.*'

No more grepping human-intended messages!

(or, better yet, make your voice heard in this still open 2017 request for a script-friendly interface)

I feel your pain... I also love the sudo-less power of udisksctl, I use UDisks2 in several snippets and projects, and I also hate how "machine-unfriendly" its output is.

That said, one approach I'm leaning towards to is not to parse the output of udisksctl mount,loop-*,..., use it for actions only, and leave parsing to udisksctl info, udevadm or even lsblk -lnpb (which can even have JSON output if you're willing to use jq!).

If you do parse udisksctl, at least prepend it with LC_ALL=C to avoid localized messages by using the fixed C "virtual" locale, so you at least guarantee the strings matched won't change per user environment.

Examples:

  • Listing the (writable) partitions with a known filesystem of a drive device (if any):
lsblk "$device" -lnpb --output NAME,RO,FSTYPE | awk '$2 == 0 && $3 {print $1}'
  • Getting the mountpoint of one such partition above after mounting:
LC_ALL=C udisksctl info -b "$partition" | grep -Po '^ *MountPoints: *\K.*'

No more grepping human-intended messages!

(or, better yet, make your voice heard in this still open 2017 request for a script-friendly interface)

deleted 20 characters in body
Source Link
MestreLion
  • 1.6k
  • 17
  • 22

I feel your pain... I also love the sudo-less power of udisksctl, I use UDisks2 in several snippets and projects, and I also hate how "machine-unfriendly" its output is.

That said, one approach I'm leaning towards to is not to parse the output of udisksctl mount,loop-*,..., use it for actions only, and leave parsing to udisksctl info, udevadm or even lsblk -lnpb (which can even hashave JSON output if you're willing to use jq!).

If you do parse udisksctl, at least prepend it with LC_ALL=C to avoid localized messages by using the fixed C "virtual" locale, so you at least guarantee the strings matched won't change per user environment.

Examples:

  • Listing the (writable) partitions with a known filesystem of a drive device (if any):
lsblk "$device" -lnpb --output NAME,RO,FSTYPE | awk '$2 == 0 && $3 {print $1}'
  • Getting the mountpoint of one such partition above after mounting:
LC_ALL=C udisksctl info -b "$partition" | grep -Po '^ *MountPoints: *\K.*'

No more grepping human-intended messages!

(or, better yet, make your voice heard in this still open 2017 request for a script-friendly interface)

I feel your pain... I also love the sudo-less power of udisksctl, I use UDisks2 in several snippets and projects, and I also hate how "machine-unfriendly" its output is.

That said, one approach I'm leaning towards to is not to parse the output of udisksctl mount,loop-*,..., use it for actions only, and leave parsing to udisksctl info, udevadm or even lsblk -lnpb (which even has JSON output if you're willing to use jq!).

Examples:

  • Listing the (writable) partitions with a known filesystem of a drive device (if any):
lsblk "$device" -lnpb --output NAME,RO,FSTYPE | awk '$2 == 0 && $3 {print $1}'
  • Getting the mountpoint of one such partition above after mounting:
udisksctl info -b "$partition" | grep -Po '^ *MountPoints: *\K.*'

No more grepping human-intended messages!

(or, better yet, make your voice heard in this still open 2017 request for a script-friendly interface)

I feel your pain... I also love the sudo-less power of udisksctl, I use UDisks2 in several snippets and projects, and I also hate how "machine-unfriendly" its output is.

That said, one approach I'm leaning towards to is not to parse the output of udisksctl mount,loop-*,..., use it for actions only, and leave parsing to udisksctl info, udevadm or even lsblk -lnpb (which can even have JSON output if you're willing to use jq!).

If you do parse udisksctl, at least prepend it with LC_ALL=C to avoid localized messages by using the fixed C "virtual" locale, so you at least guarantee the strings matched won't change per user environment.

Examples:

  • Listing the (writable) partitions with a known filesystem of a drive device (if any):
lsblk "$device" -lnpb --output NAME,RO,FSTYPE | awk '$2 == 0 && $3 {print $1}'
  • Getting the mountpoint of one such partition above after mounting:
LC_ALL=C udisksctl info -b "$partition" | grep -Po '^ *MountPoints: *\K.*'

No more grepping human-intended messages!

(or, better yet, make your voice heard in this still open 2017 request for a script-friendly interface)

deleted 20 characters in body
Source Link
MestreLion
  • 1.6k
  • 17
  • 22

I feel your pain... I also love the sudo-less power of udisksctl, I use UDisks2 in several snippets and projects, and I also hate how "machine-unfriendly" its output is.

That said, one approach I'm leaning towards to is not to parse the output of udisksctl mount,loop-*,..., use it for actions only, and leave parsing to udisksctl info, udevadm or even lsblk -lnpb (which even has JSON output if you're willing to use jq!).

Examples:

  • Listing the (writable) partitions with a known filesystem of a drive device (if any):
lsblk "$device" -lnpb --output NAME,RO,FSTYPE | awk '$2 == 0 && $3 {print $1}'
  • Getting the mountpoint of one such partition above after mounting:
udisksctl info -b "$partition" | grep '^ *MountPoints:' | sed-Po 's/^'^ *MountPoints: *//'*\K.*'

No more grepping human-intended messages!

(or, better yet, make your voice heard in this still open 2017 request for a script-friendly interface)

I feel your pain... I also love the sudo-less power of udisksctl, I use UDisks2 in several snippets and projects, and I also hate how "machine-unfriendly" its output is.

That said, one approach I'm leaning towards to is not to parse the output of udisksctl mount,loop-*,..., use it for actions only, and leave parsing to udisksctl info, udevadm or even lsblk -lnpb (which even has JSON output if you're willing to use jq!).

Examples:

  • Listing the (writable) partitions with a known filesystem of a drive device (if any):
lsblk "$device" -lnpb --output NAME,RO,FSTYPE | awk '$2 == 0 && $3 {print $1}'
  • Getting the mountpoint of one such partition above after mounting:
udisksctl info -b "$partition" | grep '^ *MountPoints:' | sed 's/^ *MountPoints: *//'

No more grepping human-intended messages!

(or, better yet, make your voice heard in this still open 2017 request for a script-friendly interface)

I feel your pain... I also love the sudo-less power of udisksctl, I use UDisks2 in several snippets and projects, and I also hate how "machine-unfriendly" its output is.

That said, one approach I'm leaning towards to is not to parse the output of udisksctl mount,loop-*,..., use it for actions only, and leave parsing to udisksctl info, udevadm or even lsblk -lnpb (which even has JSON output if you're willing to use jq!).

Examples:

  • Listing the (writable) partitions with a known filesystem of a drive device (if any):
lsblk "$device" -lnpb --output NAME,RO,FSTYPE | awk '$2 == 0 && $3 {print $1}'
  • Getting the mountpoint of one such partition above after mounting:
udisksctl info -b "$partition" | grep -Po '^ *MountPoints: *\K.*'

No more grepping human-intended messages!

(or, better yet, make your voice heard in this still open 2017 request for a script-friendly interface)

added 162 characters in body
Source Link
MestreLion
  • 1.6k
  • 17
  • 22
Loading
Source Link
MestreLion
  • 1.6k
  • 17
  • 22
Loading