Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Error executing;  df -k|grep vx|awk '(x+=$2) END (print x/1024/1024)'

Posted on 2011-10-28
11
Medium Priority
?
741 Views
Last Modified: 2013-12-27
Hi experts.  Executing the following command gave me an error:
this is for summarizing the first column of the result of df -k

aais2:/export/home/oracle> df -k |awk '(x+=$1) END (print x)'
awk: syntax error near line 1
awk: bailing out near line 1
aais2:/export/home/oracle> df -k|grep vx|awk '(x+=$2) END (print x/1024/1024)'
awk: syntax error near line 1
awk: bailing out near line 1
0
Comment
Question by:LindaC
  • 5
  • 4
  • 2
11 Comments
 
LVL 31

Expert Comment

by:farzanj
ID: 37045601
Try
df -k|grep vx|awk '(x+=$2) ;END {print x/1024/1024}'
0
 
LVL 8

Author Comment

by:LindaC
ID: 37046090
I'am doing this as the oracle user:

aais2:/export/home/oracle> df -k|grep vx|awk '(x+=$2) ;END {print x/1024/1024}'
awk: syntax error near line 1
awk: bailing out near line 1
0
 
LVL 31

Expert Comment

by:farzanj
ID: 37046144
Well, works perfectly for me.
$ df -k|grep vx|awk '(x+=$2) ;END {print x/1024/1024}'
0


Try this
$ df -k|grep vx|awk '{ x+=$2 }; END {print x/1024/1024}'


Or
df -k|grep vx | gawk '{ sum += $2 }; END { print sum }'
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 8

Author Comment

by:LindaC
ID: 37046192
# df -k|grep vx|awk '{ x+=$2 }; END {print x/1024/1024}'
0
# df -k|grep vx | gawk '{ sum += $2 }; END { print sum }'
gawk: not found
# df -k|grep vx | awk '{ sum += $2 }; END { print sum }'

#

What I want is the column #1 summarized:

# df -k
Filesystem            kbytes    used   avail capacity  Mounted on
/                    109359020 42689997 65575433    40%    /
/aais2/AAIS/ora1     46137344 31792189 13469234    71%    /aais2/AAIS/ora1
/aais2/AAIS/ora10    44040192 27117552 15864981    64%    /aais2/AAIS/ora10
/aais2/AAIS/ora2     65294827 47523578 16660613    75%    /aais2/AAIS/ora2
/aais2/AAIS/ora3     52428800 36521303 14913284    72%    /aais2/AAIS/ora3
/aais2/AAIS/ora4     52428800 24123875 26537216    48%    /aais2/AAIS/ora4
/aais2/AAIS/ora5     79167488 44510985 32490477    58%    /aais2/AAIS/ora5
/aais2/AAIS/ora6     44040192 29523159 13609788    69%    /aais2/AAIS/ora6
/aais2/AAIS/ora7     33554432 17820442 14750942    55%    /aais2/AAIS/ora7
/aais2/AAIS/ora8     70254592 37015561 31161915    55%    /aais2/AAIS/ora8
/aais2/AAIS/ora9     54525952 32900734 20273647    62%    /aais2/AAIS/ora9
/dataserver          56573820 44069047 11751380    79%    /dataserver
/dataserver/migration
                     31457280 8723799 21316904    30%    /dataserver/migration
/dataserver_tmp      33554432 9889788 22195132    31%    /dataserver_tmp
/dev                 109359020 42689997 65575433    40%    /dev
/export/home         22966960 4210215 17584561    20%    /export/home
/home                8388608 4894398 3276725    60%    /home
proc                       0       0       0     0%    /proc
ctfs                       0       0       0     0%    /system/contract
mnttab                     0       0       0     0%    /etc/mnttab
objfs                      0       0       0     0%    /system/object
swap                 53916592     384 53916208     1%    /etc/svc/volatile
fd                         0       0       0     0%    /dev/fd
swap                 55434480 1518272 53916208     3%    /tmp
swap                 53916248      40 53916208     1%    /var/run
# df -h
Filesystem             size   used  avail capacity  Mounted on
/                      104G    41G    63G    40%    /
/aais2/AAIS/ora1        44G    30G    13G    71%    /aais2/AAIS/ora1
/aais2/AAIS/ora10       42G    26G    15G    64%    /aais2/AAIS/ora10
/aais2/AAIS/ora2        62G    45G    16G    75%    /aais2/AAIS/ora2
/aais2/AAIS/ora3        50G    35G    14G    72%    /aais2/AAIS/ora3
/aais2/AAIS/ora4        50G    23G    25G    48%    /aais2/AAIS/ora4
/aais2/AAIS/ora5        76G    42G    31G    58%    /aais2/AAIS/ora5
/aais2/AAIS/ora6        42G    28G    13G    69%    /aais2/AAIS/ora6
/aais2/AAIS/ora7        32G    17G    14G    55%    /aais2/AAIS/ora7
/aais2/AAIS/ora8        67G    35G    30G    55%    /aais2/AAIS/ora8
/aais2/AAIS/ora9        52G    31G    19G    62%    /aais2/AAIS/ora9
/dataserver             54G    42G    11G    79%    /dataserver
/dataserver/migration
                        30G   8.3G    20G    30%    /dataserver/migration
/dataserver_tmp         32G   9.4G    21G    31%    /dataserver_tmp
/dev                   104G    41G    63G    40%    /dev
/export/home            22G   4.0G    17G    20%    /export/home
/home                  8.0G   4.7G   3.1G    60%    /home
proc                     0K     0K     0K     0%    /proc
ctfs                     0K     0K     0K     0%    /system/contract
mnttab                   0K     0K     0K     0%    /etc/mnttab
objfs                    0K     0K     0K     0%    /system/object
swap                    51G   384K    51G     1%    /etc/svc/volatile
fd                       0K     0K     0K     0%    /dev/fd
swap                    53G   1.4G    51G     3%    /tmp
swap                    51G    40K    51G     1%    /var/run
#
0
 
LVL 31

Expert Comment

by:farzanj
ID: 37046317
Remove grep
0
 
LVL 8

Author Comment

by:LindaC
ID: 37046474
aais2:/export/home/oracle> df -k vx|awk '(x+=$2) END (print x/1024/1024)'
df: (vx        ) not a block device, directory or mounted resource
awk: syntax error near line 1
awk: bailing out near line 1
aais2:/export/home/oracle> df -k | vx|awk '(x+=$2) END (print x/1024/1024)'
awk: syntax error near line 1
awk: bailing out near line 1
ksh: vx: cannot execute
aais2:/export/home/oracle>
0
 
LVL 31

Expert Comment

by:farzanj
ID: 37046703
Well.  Why were you grepping vx anyway?

Why do you have a vx?  Please remove that too and the pipe after that
0
 
LVL 48

Accepted Solution

by:
Tintin earned 2000 total points
ID: 37046930
If you want a total size of all your filesystems (excluding special ones like proc/swap), then do
df -k | grep / |awk '{t+=$2} END {print t/1024/1024}'

Open in new window

0
 
LVL 8

Author Comment

by:LindaC
ID: 37047181
Is this the space allocated?

aais2:/export/home/oracle> df -k | grep / |awk '{t+=$2} END {print t/1024/1024}'
1025.08
0
 
LVL 48

Expert Comment

by:Tintin
ID: 37048267
yes, space allocated.
0
 
LVL 8

Author Closing Comment

by:LindaC
ID: 37048627
Thank you.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Suggested Courses
Course of the Month21 days, 6 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question