Store output diskspace df -h JSON
I am attempting to gather basic disk space information from a server using a bash script, and store the output in JSON format. I am looking to record the available & used disk space.
An example output of df -h:
Filesystem Size Used Avail Use% Mounted on
udev 2.0G 4.0K 2.0G 1% /dev
tmpfs 394M 288K 394M 1% /run
/dev/mapper/nodequery--vg-root 45G 1.4G 41G 4% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
none 5.0M 0 5.0M 0% /run/lock
none 2.0G 0 2.0G 0% /run/shm
none 100M 0 100M 0% /run/user
/dev/sda2 237M 47M 178M 21% /boot
/dev/sda1 511M 3.4M 508M 1% /boot/efi
As an example this is how I would like the final output to look.
{
"diskarray": [{
"mount": "/dev/disk1",
"spacetotal": "35GB",
"spaceavail": "1GB"
},
{
"mount": "/dev/disk2",
"spacetotal": "35GB",
"spaceavail": "4GB"
}]
}
So far I've tried using awk:
df -P -B 1 | grep '^/' | awk '{ print $1" "$2" "$3";" }'
with the following output:
/dev/mapper/nodequery--vg-root 47710605312 1439592448;
/dev/sda2 247772160 48645120;
/dev/sda1 535805952 3538944;
But I'm not sure how I take that data and store it in the JSON format.
json bash
|
show 2 more comments
I am attempting to gather basic disk space information from a server using a bash script, and store the output in JSON format. I am looking to record the available & used disk space.
An example output of df -h:
Filesystem Size Used Avail Use% Mounted on
udev 2.0G 4.0K 2.0G 1% /dev
tmpfs 394M 288K 394M 1% /run
/dev/mapper/nodequery--vg-root 45G 1.4G 41G 4% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
none 5.0M 0 5.0M 0% /run/lock
none 2.0G 0 2.0G 0% /run/shm
none 100M 0 100M 0% /run/user
/dev/sda2 237M 47M 178M 21% /boot
/dev/sda1 511M 3.4M 508M 1% /boot/efi
As an example this is how I would like the final output to look.
{
"diskarray": [{
"mount": "/dev/disk1",
"spacetotal": "35GB",
"spaceavail": "1GB"
},
{
"mount": "/dev/disk2",
"spacetotal": "35GB",
"spaceavail": "4GB"
}]
}
So far I've tried using awk:
df -P -B 1 | grep '^/' | awk '{ print $1" "$2" "$3";" }'
with the following output:
/dev/mapper/nodequery--vg-root 47710605312 1439592448;
/dev/sda2 247772160 48645120;
/dev/sda1 535805952 3538944;
But I'm not sure how I take that data and store it in the JSON format.
json bash
I've got to this: df -P -B 1 | grep '^/' | awk '{ print $1" "$2" "$3";" }'
– westcoastdev
Feb 4 '16 at 21:14
1
You should edit your question to include your attempted solution, and tell us what problems you're having with it. You will get better reaction to "here's what I tried, and here's how it doesn't work" rather than "I want to do this, tell me how."
– miken32
Feb 4 '16 at 21:17
Sorry i edited, fairly new to this site & bash in general, going off other examples I've found doing similar things.
– westcoastdev
Feb 4 '16 at 21:19
Have you looked atjq
(a tool built for this kind of use case)?
– Charles Duffy
Feb 4 '16 at 21:21
@CharlesDuffy , I will take a look at that although I am trying to avoid having package requirements for the script to run
– westcoastdev
Feb 4 '16 at 21:28
|
show 2 more comments
I am attempting to gather basic disk space information from a server using a bash script, and store the output in JSON format. I am looking to record the available & used disk space.
An example output of df -h:
Filesystem Size Used Avail Use% Mounted on
udev 2.0G 4.0K 2.0G 1% /dev
tmpfs 394M 288K 394M 1% /run
/dev/mapper/nodequery--vg-root 45G 1.4G 41G 4% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
none 5.0M 0 5.0M 0% /run/lock
none 2.0G 0 2.0G 0% /run/shm
none 100M 0 100M 0% /run/user
/dev/sda2 237M 47M 178M 21% /boot
/dev/sda1 511M 3.4M 508M 1% /boot/efi
As an example this is how I would like the final output to look.
{
"diskarray": [{
"mount": "/dev/disk1",
"spacetotal": "35GB",
"spaceavail": "1GB"
},
{
"mount": "/dev/disk2",
"spacetotal": "35GB",
"spaceavail": "4GB"
}]
}
So far I've tried using awk:
df -P -B 1 | grep '^/' | awk '{ print $1" "$2" "$3";" }'
with the following output:
/dev/mapper/nodequery--vg-root 47710605312 1439592448;
/dev/sda2 247772160 48645120;
/dev/sda1 535805952 3538944;
But I'm not sure how I take that data and store it in the JSON format.
json bash
I am attempting to gather basic disk space information from a server using a bash script, and store the output in JSON format. I am looking to record the available & used disk space.
An example output of df -h:
Filesystem Size Used Avail Use% Mounted on
udev 2.0G 4.0K 2.0G 1% /dev
tmpfs 394M 288K 394M 1% /run
/dev/mapper/nodequery--vg-root 45G 1.4G 41G 4% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
none 5.0M 0 5.0M 0% /run/lock
none 2.0G 0 2.0G 0% /run/shm
none 100M 0 100M 0% /run/user
/dev/sda2 237M 47M 178M 21% /boot
/dev/sda1 511M 3.4M 508M 1% /boot/efi
As an example this is how I would like the final output to look.
{
"diskarray": [{
"mount": "/dev/disk1",
"spacetotal": "35GB",
"spaceavail": "1GB"
},
{
"mount": "/dev/disk2",
"spacetotal": "35GB",
"spaceavail": "4GB"
}]
}
So far I've tried using awk:
df -P -B 1 | grep '^/' | awk '{ print $1" "$2" "$3";" }'
with the following output:
/dev/mapper/nodequery--vg-root 47710605312 1439592448;
/dev/sda2 247772160 48645120;
/dev/sda1 535805952 3538944;
But I'm not sure how I take that data and store it in the JSON format.
json bash
json bash
edited Feb 4 '16 at 21:19
westcoastdev
asked Feb 4 '16 at 21:12
westcoastdevwestcoastdev
234
234
I've got to this: df -P -B 1 | grep '^/' | awk '{ print $1" "$2" "$3";" }'
– westcoastdev
Feb 4 '16 at 21:14
1
You should edit your question to include your attempted solution, and tell us what problems you're having with it. You will get better reaction to "here's what I tried, and here's how it doesn't work" rather than "I want to do this, tell me how."
– miken32
Feb 4 '16 at 21:17
Sorry i edited, fairly new to this site & bash in general, going off other examples I've found doing similar things.
– westcoastdev
Feb 4 '16 at 21:19
Have you looked atjq
(a tool built for this kind of use case)?
– Charles Duffy
Feb 4 '16 at 21:21
@CharlesDuffy , I will take a look at that although I am trying to avoid having package requirements for the script to run
– westcoastdev
Feb 4 '16 at 21:28
|
show 2 more comments
I've got to this: df -P -B 1 | grep '^/' | awk '{ print $1" "$2" "$3";" }'
– westcoastdev
Feb 4 '16 at 21:14
1
You should edit your question to include your attempted solution, and tell us what problems you're having with it. You will get better reaction to "here's what I tried, and here's how it doesn't work" rather than "I want to do this, tell me how."
– miken32
Feb 4 '16 at 21:17
Sorry i edited, fairly new to this site & bash in general, going off other examples I've found doing similar things.
– westcoastdev
Feb 4 '16 at 21:19
Have you looked atjq
(a tool built for this kind of use case)?
– Charles Duffy
Feb 4 '16 at 21:21
@CharlesDuffy , I will take a look at that although I am trying to avoid having package requirements for the script to run
– westcoastdev
Feb 4 '16 at 21:28
I've got to this: df -P -B 1 | grep '^/' | awk '{ print $1" "$2" "$3";" }'
– westcoastdev
Feb 4 '16 at 21:14
I've got to this: df -P -B 1 | grep '^/' | awk '{ print $1" "$2" "$3";" }'
– westcoastdev
Feb 4 '16 at 21:14
1
1
You should edit your question to include your attempted solution, and tell us what problems you're having with it. You will get better reaction to "here's what I tried, and here's how it doesn't work" rather than "I want to do this, tell me how."
– miken32
Feb 4 '16 at 21:17
You should edit your question to include your attempted solution, and tell us what problems you're having with it. You will get better reaction to "here's what I tried, and here's how it doesn't work" rather than "I want to do this, tell me how."
– miken32
Feb 4 '16 at 21:17
Sorry i edited, fairly new to this site & bash in general, going off other examples I've found doing similar things.
– westcoastdev
Feb 4 '16 at 21:19
Sorry i edited, fairly new to this site & bash in general, going off other examples I've found doing similar things.
– westcoastdev
Feb 4 '16 at 21:19
Have you looked at
jq
(a tool built for this kind of use case)?– Charles Duffy
Feb 4 '16 at 21:21
Have you looked at
jq
(a tool built for this kind of use case)?– Charles Duffy
Feb 4 '16 at 21:21
@CharlesDuffy , I will take a look at that although I am trying to avoid having package requirements for the script to run
– westcoastdev
Feb 4 '16 at 21:28
@CharlesDuffy , I will take a look at that although I am trying to avoid having package requirements for the script to run
– westcoastdev
Feb 4 '16 at 21:28
|
show 2 more comments
3 Answers
3
active
oldest
votes
The following does what you want, with the only requirement external to bash being a Python interpreter:
python_script=$(cat <<'EOF'
import sys, json
data = {'diskarray': }
for line in sys.stdin.readlines():
mount, avail, total = line.rstrip(';').split()
data['diskarray'].append(dict(mount=mount, spacetotal=total, spaceavail=avail))
sys.stdout.write(json.dumps(data))
EOF
)
df -Ph | awk '/^// { print $1" "$2" "$3";" }' | python -c "$python_script"
An alternate implementation using jq
might look like this:
df -Ph |
jq -R -s '
[
split("n") |
. |
if test("^/") then
gsub(" +"; " ") | split(" ") | {mount: .[0], spacetotal: .[1], spaceavail: .[2]}
else
empty
end
]'
This is exactly what I was looking to do. Thank you so much!
– westcoastdev
Feb 4 '16 at 21:52
Glad to help! I've also added ajq
implementation (that also does the work ofawk
internally).
– Charles Duffy
Feb 4 '16 at 23:27
add a comment |
You can do:
$ df -Ph | awk '/^// {print $1"t"$2"t"$4}' | python -c 'import json, fileinput; print json.dumps({"diskarray":[dict(zip(("mount", "spacetotal", "spaceavail"), l.split())) for l in fileinput.input()]}, indent=2)'
{
"diskarray": [
{
"mount": "/dev/disk1",
"spacetotal": "931Gi",
"spaceavail": "623Gi"
},
{
"mount": "/dev/disk2s2",
"spacetotal": "1.8Ti",
"spaceavail": "360Gi"
}
]
}
add a comment |
Alternative Oneliner
$ df -hP | awk 'BEGIN {printf"{"discarray":["}{if($1=="Filesystem")next;if(a)printf",";printf"{"mount":""$6"","size":""$2"","used":""$3"","avail":""$4"","use%":""$4""}";a++;}END{print"]}";}'
{
"discarray":[
{
"mount":"/",
"size":"3.9G",
"used":"2.2G",
"avail":"1.5G",
"use%":"1.5G"
},
{
"mount":"/dev",
"size":"24G",
"used":"0",
"avail":"24G",
"use%":"24G"
}
]
}
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f35211716%2fstore-output-diskspace-df-h-json%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
The following does what you want, with the only requirement external to bash being a Python interpreter:
python_script=$(cat <<'EOF'
import sys, json
data = {'diskarray': }
for line in sys.stdin.readlines():
mount, avail, total = line.rstrip(';').split()
data['diskarray'].append(dict(mount=mount, spacetotal=total, spaceavail=avail))
sys.stdout.write(json.dumps(data))
EOF
)
df -Ph | awk '/^// { print $1" "$2" "$3";" }' | python -c "$python_script"
An alternate implementation using jq
might look like this:
df -Ph |
jq -R -s '
[
split("n") |
. |
if test("^/") then
gsub(" +"; " ") | split(" ") | {mount: .[0], spacetotal: .[1], spaceavail: .[2]}
else
empty
end
]'
This is exactly what I was looking to do. Thank you so much!
– westcoastdev
Feb 4 '16 at 21:52
Glad to help! I've also added ajq
implementation (that also does the work ofawk
internally).
– Charles Duffy
Feb 4 '16 at 23:27
add a comment |
The following does what you want, with the only requirement external to bash being a Python interpreter:
python_script=$(cat <<'EOF'
import sys, json
data = {'diskarray': }
for line in sys.stdin.readlines():
mount, avail, total = line.rstrip(';').split()
data['diskarray'].append(dict(mount=mount, spacetotal=total, spaceavail=avail))
sys.stdout.write(json.dumps(data))
EOF
)
df -Ph | awk '/^// { print $1" "$2" "$3";" }' | python -c "$python_script"
An alternate implementation using jq
might look like this:
df -Ph |
jq -R -s '
[
split("n") |
. |
if test("^/") then
gsub(" +"; " ") | split(" ") | {mount: .[0], spacetotal: .[1], spaceavail: .[2]}
else
empty
end
]'
This is exactly what I was looking to do. Thank you so much!
– westcoastdev
Feb 4 '16 at 21:52
Glad to help! I've also added ajq
implementation (that also does the work ofawk
internally).
– Charles Duffy
Feb 4 '16 at 23:27
add a comment |
The following does what you want, with the only requirement external to bash being a Python interpreter:
python_script=$(cat <<'EOF'
import sys, json
data = {'diskarray': }
for line in sys.stdin.readlines():
mount, avail, total = line.rstrip(';').split()
data['diskarray'].append(dict(mount=mount, spacetotal=total, spaceavail=avail))
sys.stdout.write(json.dumps(data))
EOF
)
df -Ph | awk '/^// { print $1" "$2" "$3";" }' | python -c "$python_script"
An alternate implementation using jq
might look like this:
df -Ph |
jq -R -s '
[
split("n") |
. |
if test("^/") then
gsub(" +"; " ") | split(" ") | {mount: .[0], spacetotal: .[1], spaceavail: .[2]}
else
empty
end
]'
The following does what you want, with the only requirement external to bash being a Python interpreter:
python_script=$(cat <<'EOF'
import sys, json
data = {'diskarray': }
for line in sys.stdin.readlines():
mount, avail, total = line.rstrip(';').split()
data['diskarray'].append(dict(mount=mount, spacetotal=total, spaceavail=avail))
sys.stdout.write(json.dumps(data))
EOF
)
df -Ph | awk '/^// { print $1" "$2" "$3";" }' | python -c "$python_script"
An alternate implementation using jq
might look like this:
df -Ph |
jq -R -s '
[
split("n") |
. |
if test("^/") then
gsub(" +"; " ") | split(" ") | {mount: .[0], spacetotal: .[1], spaceavail: .[2]}
else
empty
end
]'
edited Feb 4 '16 at 23:25
answered Feb 4 '16 at 21:40
Charles DuffyCharles Duffy
178k25200256
178k25200256
This is exactly what I was looking to do. Thank you so much!
– westcoastdev
Feb 4 '16 at 21:52
Glad to help! I've also added ajq
implementation (that also does the work ofawk
internally).
– Charles Duffy
Feb 4 '16 at 23:27
add a comment |
This is exactly what I was looking to do. Thank you so much!
– westcoastdev
Feb 4 '16 at 21:52
Glad to help! I've also added ajq
implementation (that also does the work ofawk
internally).
– Charles Duffy
Feb 4 '16 at 23:27
This is exactly what I was looking to do. Thank you so much!
– westcoastdev
Feb 4 '16 at 21:52
This is exactly what I was looking to do. Thank you so much!
– westcoastdev
Feb 4 '16 at 21:52
Glad to help! I've also added a
jq
implementation (that also does the work of awk
internally).– Charles Duffy
Feb 4 '16 at 23:27
Glad to help! I've also added a
jq
implementation (that also does the work of awk
internally).– Charles Duffy
Feb 4 '16 at 23:27
add a comment |
You can do:
$ df -Ph | awk '/^// {print $1"t"$2"t"$4}' | python -c 'import json, fileinput; print json.dumps({"diskarray":[dict(zip(("mount", "spacetotal", "spaceavail"), l.split())) for l in fileinput.input()]}, indent=2)'
{
"diskarray": [
{
"mount": "/dev/disk1",
"spacetotal": "931Gi",
"spaceavail": "623Gi"
},
{
"mount": "/dev/disk2s2",
"spacetotal": "1.8Ti",
"spaceavail": "360Gi"
}
]
}
add a comment |
You can do:
$ df -Ph | awk '/^// {print $1"t"$2"t"$4}' | python -c 'import json, fileinput; print json.dumps({"diskarray":[dict(zip(("mount", "spacetotal", "spaceavail"), l.split())) for l in fileinput.input()]}, indent=2)'
{
"diskarray": [
{
"mount": "/dev/disk1",
"spacetotal": "931Gi",
"spaceavail": "623Gi"
},
{
"mount": "/dev/disk2s2",
"spacetotal": "1.8Ti",
"spaceavail": "360Gi"
}
]
}
add a comment |
You can do:
$ df -Ph | awk '/^// {print $1"t"$2"t"$4}' | python -c 'import json, fileinput; print json.dumps({"diskarray":[dict(zip(("mount", "spacetotal", "spaceavail"), l.split())) for l in fileinput.input()]}, indent=2)'
{
"diskarray": [
{
"mount": "/dev/disk1",
"spacetotal": "931Gi",
"spaceavail": "623Gi"
},
{
"mount": "/dev/disk2s2",
"spacetotal": "1.8Ti",
"spaceavail": "360Gi"
}
]
}
You can do:
$ df -Ph | awk '/^// {print $1"t"$2"t"$4}' | python -c 'import json, fileinput; print json.dumps({"diskarray":[dict(zip(("mount", "spacetotal", "spaceavail"), l.split())) for l in fileinput.input()]}, indent=2)'
{
"diskarray": [
{
"mount": "/dev/disk1",
"spacetotal": "931Gi",
"spaceavail": "623Gi"
},
{
"mount": "/dev/disk2s2",
"spacetotal": "1.8Ti",
"spaceavail": "360Gi"
}
]
}
edited Feb 4 '16 at 22:12
answered Feb 4 '16 at 21:57
dawgdawg
59.4k1283153
59.4k1283153
add a comment |
add a comment |
Alternative Oneliner
$ df -hP | awk 'BEGIN {printf"{"discarray":["}{if($1=="Filesystem")next;if(a)printf",";printf"{"mount":""$6"","size":""$2"","used":""$3"","avail":""$4"","use%":""$4""}";a++;}END{print"]}";}'
{
"discarray":[
{
"mount":"/",
"size":"3.9G",
"used":"2.2G",
"avail":"1.5G",
"use%":"1.5G"
},
{
"mount":"/dev",
"size":"24G",
"used":"0",
"avail":"24G",
"use%":"24G"
}
]
}
add a comment |
Alternative Oneliner
$ df -hP | awk 'BEGIN {printf"{"discarray":["}{if($1=="Filesystem")next;if(a)printf",";printf"{"mount":""$6"","size":""$2"","used":""$3"","avail":""$4"","use%":""$4""}";a++;}END{print"]}";}'
{
"discarray":[
{
"mount":"/",
"size":"3.9G",
"used":"2.2G",
"avail":"1.5G",
"use%":"1.5G"
},
{
"mount":"/dev",
"size":"24G",
"used":"0",
"avail":"24G",
"use%":"24G"
}
]
}
add a comment |
Alternative Oneliner
$ df -hP | awk 'BEGIN {printf"{"discarray":["}{if($1=="Filesystem")next;if(a)printf",";printf"{"mount":""$6"","size":""$2"","used":""$3"","avail":""$4"","use%":""$4""}";a++;}END{print"]}";}'
{
"discarray":[
{
"mount":"/",
"size":"3.9G",
"used":"2.2G",
"avail":"1.5G",
"use%":"1.5G"
},
{
"mount":"/dev",
"size":"24G",
"used":"0",
"avail":"24G",
"use%":"24G"
}
]
}
Alternative Oneliner
$ df -hP | awk 'BEGIN {printf"{"discarray":["}{if($1=="Filesystem")next;if(a)printf",";printf"{"mount":""$6"","size":""$2"","used":""$3"","avail":""$4"","use%":""$4""}";a++;}END{print"]}";}'
{
"discarray":[
{
"mount":"/",
"size":"3.9G",
"used":"2.2G",
"avail":"1.5G",
"use%":"1.5G"
},
{
"mount":"/dev",
"size":"24G",
"used":"0",
"avail":"24G",
"use%":"24G"
}
]
}
answered Nov 22 '18 at 13:33
MagnusMagnus
1
1
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f35211716%2fstore-output-diskspace-df-h-json%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I've got to this: df -P -B 1 | grep '^/' | awk '{ print $1" "$2" "$3";" }'
– westcoastdev
Feb 4 '16 at 21:14
1
You should edit your question to include your attempted solution, and tell us what problems you're having with it. You will get better reaction to "here's what I tried, and here's how it doesn't work" rather than "I want to do this, tell me how."
– miken32
Feb 4 '16 at 21:17
Sorry i edited, fairly new to this site & bash in general, going off other examples I've found doing similar things.
– westcoastdev
Feb 4 '16 at 21:19
Have you looked at
jq
(a tool built for this kind of use case)?– Charles Duffy
Feb 4 '16 at 21:21
@CharlesDuffy , I will take a look at that although I am trying to avoid having package requirements for the script to run
– westcoastdev
Feb 4 '16 at 21:28