Tag Info

Hot answers tagged

5

To list all partitions defined for a device as root run: lsblk OR fdisk -l OR cat /proc/partitions And also as mentioned by @Giedrius Rekasius fdisk -l /dev/sda | grep '^/dev' | cut -d' ' -f1


3

df will display only mounted partitions. If that's what you want then to extract the device nodes from df output you grep for the lines starting with "/dev" and cut the first column out of the remaining output: df | grep '^/dev' | cut -d' ' -f1 or to list them on a single line separated by spaces: df | grep '^/dev' | cut -d' ' -f1 | tr '\n' ' ' If you ...


2

Some ideas... awk '{print $1}' /proc/mounts df | awk '{print $1}' df | cut -f1 -d " "


1

What about : df | cut -d" " -f1


1

Another option: df --type ext2 --type ext3 --type ext4 | tail -n +2 | awk '{ print $1 }' | tr '\n' ' ' --type <filesystem> allows you to specify which filesystems you are interested in tail -n +2 starts printing from the second row of output (so that the heading line isn't printed) awk '{ print $1 }' will print the leftmost column which contains ...


1

blkid displays just real storages attached to computer with or without mounted. # sudo blkid | awk '{print substr($1, 0, length($1) - 1)}' /dev/sda1 /dev/sda2 /dev/sdb1 /dev/sdb2 /dev/sr1


1

You should read BashFAQ/050 aka I'm trying to put a command in a variable, but the complex cases always fail!. A TL;DR: This fails because [...] the [...] quotes inside the variable are literal; not syntactical. Word splitting is also a problem when trying to store a command in a variable. Although not with your immediate example this is something one ...



Only top voted, non community-wiki answers of a minimum length are eligible