« first day (1450 days earlier)      last day (1603 days later) » 

5:22 AM
@Queen k
@Queen k (3 votes]
@Queen f
 
 
6 hours later…
11:04 AM
@tripleee : hi ... is there a really complicated way to get the sort of output you gen from df but without using df ?
the more complicated the better
silly I know but I got asked a stupid question so I will give them what they deserve
 
11:23 AM
@louigi600 uh you mean complicated in terms of human-readable fields which may or may not fold? or complicated because there are many columns? and df-like specifically in terms of disk capacity usage, or just the general formatting?
top and iostat have vaguely similar output with lots of columns
or do you mean complicated in terms of a complex command line? anything that is an actual program is going to be harder to grok for a newcomer than simple command-line options; dd has hairy option syntax but it's just different, not particularly more complex than e.g. tar or ps
stackoverflow.com/a/38740102/874188 isn't terribly complex but suggestive of what I have in mind for an "actual program"
though the final output is not at all complicated
 
 
1 hour later…
12:40 PM
no I mean in terms of a daft way to do it because it is so much simpler with df
I found this:
for fs in $(grep -o '/dev/sd..' /proc/mounts)
do
stat -f $fs
done

but the inodecount is off ... so I'm sure I can do better
 
@louigi600 I don't have /proc/mounts but if that works on Linux, it looks pretty reasonable actually
you might want to pipe to Awk to format in columns and calculcate percentages etc if that is desired
 
I will fiddle with -c and tell it what I want so I fet all the info needed
 
these are all horribly platform-dependent, stat is different on BSD too
 
instead of using -f flag
it's for a lunux system
so don't worry too much
this is a good exacise but for a really stupid reason :D
 
you could avoid the explicit loop with grep -o '/dev/sd..' /proc/mounts | xargs stat whatever
device names are probably reasonably consistent on modern Linux, they too will have different names on e.g. a Mac
my root partition seems to be /dev/disk1s1
historically Linux had /dev/hdaX etc
and I guess RAID and/or LVM might put different device names too
 
12:58 PM
using --print in stat
which one will give me the total,used and free block  and inode count ?
%s gives me 0 on root which is not true
and also the %f gives me something that looks hex:
# stat  --print "free blocks: %f %s\ninode:%i\n"  /dev/sda3
free blocks: 61b0 0
inode:7214
ahh wait ...
stat -f --print "free blocks: %f %s\ninode:%i\n" /dev/sda3
free blocks: 6142958 4096
 
1:14 PM
so how about this: (wit xargs I could not get this to work because of the flags)
for fs in $(grep -o '/dev/sd..' /proc/mounts)
do
tune2fs -l $fs | grep -Ei "inode|block"
done
actually i suspect it's because tune2fs will not take device to run on from redirection
grep -o '/dev/sd..' /proc/mounts | xargs tune2fs -l
tune2fs 1.41.9 (22-Aug-2009)
Usage: tune2fs [-c max_mounts_count] [-e errors_behavior] [-g group]
[-i interval[d|m|w]] [-j] [-J journal_options] [-l]
[-m reserved_blocks_percent] [-o [^]mount_options[,...]]
[-r reserved_blocks_count] [-u user] [-C mount_count] [-L volume_label]
[-M last_mounted_dir] [-O [^]feature[,...]]
[-E extended-option[,...]] [-T last_check_time] [-U UUID]
[ -I new_inode_size ] device
 
try with xargs -n 1
 
ah ... ok
grep -o '/dev/sd..' /proc/mounts | xargs -n 1 tune2fs -l | grep -Ei "inode|block"
 
some utilities do not accept a list of arguments and then you have to force it to run with one at a time
 
I read the manual .... yes I now understand why:
-n max-args
Use at most max-args arguments per command line.
@tripleee but thanks for the hint
much appreciated
 
1:45 PM
how can I allign properly multi column variable nelgth text ?
without multipass on output ?
the number of tabl to properly align is not constant ... is there a tool that helps
or do I just need to count how long is each column and tabulate accordingly ?
 
2:21 PM
column -t should do that though my Mac seems to have some problem with it - it gives me empty output
 
2:32 PM
oh my bad, I managed to feed it invalid input ... on Debian it's in bsdmainutils so it's not a standard install, but I guess fairly widely available
$ printf '1\t23423442234\t123\n72277\t6\t1234567890\nick\tpoo\tbarf\n' | column -t
1      23423442234  123
72277  6            1234567890
ick    poo          barf
10
Q: Formatting text into columns

RamI have a file with two columns as shown below(example): FILE 1: John 1 Peter 2 Michael Rod 3 Su 7 Louise 9 I need to format this and my expected output should be: FILE 1: John 1 Peter 2 Michael Rod 3 Su 7 Louise 9

TLDR column or Awk
 

« first day (1450 days earlier)      last day (1603 days later) »