The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to use cvs export remotely jasongr Shell Programming and Scripting 2 11-27-2005 08:41 PM
if statement remotely dxrmroue Shell Programming and Scripting 1 10-22-2004 11:28 AM
Using CD drive remotely ! nikk UNIX for Advanced & Expert Users 6 02-19-2002 03:03 AM
Having PROM Env remotely ! nikk UNIX for Advanced & Expert Users 1 11-11-2001 03:19 PM
Remotely login to one from another? Kagor UNIX for Dummies Questions & Answers 2 01-17-2001 06:39 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-10-2008
hcclnoodles hcclnoodles is offline
Registered User
  
 

Join Date: Mar 2002
Posts: 272
using awk remotely

Hi there

I am trying to add up the disk space used on a remote linux box but am falling at the first hurdle i.e isolating the 'space used' column with df -k on the remote box

if i run this, i get the df -k output as expected

Code:
# rsh remote-server 'df -k|grep sd|grep -v boot' 
/dev/sda3              8254272   1672956   6162020  22% /
/dev/sdb4            140258988  13405152 119729012  11% /data
/dev/sda4            123648020     32828 117334180   1% /data1
which is fine, however I want to isolate the third column, so that i can add use some additional logic to add the values to give me a total space used by that box

so i tried

Code:
# rsh remote-server 'df -k|grep sd|grep -v boot|awk {print $3} '
awk: cmd. line:2: (END OF FILE)
awk: cmd. line:2: parse error
I tried using cut, but setting the delimiter to " " (ie space) it messes up all the columns

does anybody have any idea how i can get around this ?

any help would be great
  #2 (permalink)  
Old 10-10-2008
avronius avronius is offline VIP Member  
VIP Member
  
 

Join Date: Apr 2008
Location: Calgary
Posts: 305
try this:
Code:
rsh remote-server "df -k | grep sd | grep -v boot | awk '{print $3}'"
  #3 (permalink)  
Old 10-10-2008
rubin's Avatar
rubin rubin is offline Forum Advisor  
Registered User
  
 

Join Date: Nov 2007
Posts: 321
Or maybe this might help,

Code:
rsh remote-server <<'EOF'

   df -k | awk '/sd/ && !/boot/ { print $3 }'

EOF
... And awk has its own search capabilities.
  #4 (permalink)  
Old 10-10-2008
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is offline Forum Staff  
Moderator(The Tutor)
  
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,390
yea awk has its own search capability but grep is much faster than awk..
this is my personal experience
  #5 (permalink)  
Old 10-13-2008
hcclnoodles hcclnoodles is offline
Registered User
  
 

Join Date: Mar 2002
Posts: 272
I tried the double quote option and I got this

Code:
# rsh remote-server "df -k | grep sd | grep -v boot | awk '{print $3}'"
/dev/sda3              8254272   1672772   6162204  22% /
/dev/sdb4            140258988  12922912 120211252  10% /data_store
/dev/sda4            123648020     32828 117334180   1% /data_store1
i.e. it didnt print column 3 on its own!

Quote:
Originally Posted by rubin View Post
Or maybe this might help,

Code:
rsh remote-server <<'EOF'

   df -k | awk '/sd/ && !/boot/ { print $3 }'

EOF
... And awk has its own search capabilities.


unfortunately I got this

Code:
# rsh remote-server <<'EOF'
> df -k | awk '/sd/ && !/boot/ { print $3 }'
> EOF
tcgetattr: Inappropriate ioctl for device
ioctl I_FIND ttcompat: Inappropriate ioctl for device

any other suggestions ?

Last edited by hcclnoodles; 10-13-2008 at 05:21 AM..
  #6 (permalink)  
Old 10-13-2008
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,847
Yes:

Code:
rsh host 'df -k | awk "/sd/ && !/boot/ { print \$3 }"'
  #7 (permalink)  
Old 10-13-2008
hcclnoodles hcclnoodles is offline
Registered User
  
 

Join Date: Mar 2002
Posts: 272
Quote:
Originally Posted by radoulov View Post
Yes:

Code:
rsh host 'df -k | awk "/sd/ && !/boot/ { print \$3 }"'
thats fantastic

now i just need to find a way of adding them up, thanks again for all your help guys
Sponsored Links
Closed Thread

Bookmarks

Tags
inappropriate ioctl for device

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:58 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0