nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

echo command execute df and pipe output

This is a discussion on echo command execute df and pipe output within the Shell scripting forums, part of the Development/Scripting category; when i type in this command : Code: echo " df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{print $5 ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Linux answers from nixCraft.


Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 23-05-2009, 11:28 AM
Junior Member
User
 
Join Date: May 2009
OS: Debian
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
waltjohn is on a distinguished road
Default echo command execute df and pipe output

when i type in this command :

Code:
 echo " df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{print $5 " "$1}' "
i get this output:

Code:
 df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{print }
the print variables are missing -

how do i echo this command so the print variable will show?

why are they missing.

Last edited by nixcraft; 23-05-2009 at 03:55 PM. Reason: code tag added
Reply With Quote
  #2 (permalink)  
Old 23-05-2009, 03:54 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,706
Thanks: 11
Thanked 243 Times in 183 Posts
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

Try
Code:
echo $(df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{print $5 " "$1}')
To be frank, there is no need to use echo at all:
Code:
df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{print $5 " "$1}'
FYI, this is called "Command Substitution". It allows the output of a command to replace the command name. General syntax:
Code:
var=$(command)
echo "message $(command)"
echo "Today is $(date)"
__________________
Vivek Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help

Last edited by nixcraft; 23-05-2009 at 03:57 PM.
Reply With Quote
  #3 (permalink)  
Old 23-05-2009, 10:15 PM
Junior Member
User
 
Join Date: May 2009
OS: Debian
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
waltjohn is on a distinguished road
Default

thanks - for security reasons, i dont have interent or email access at work - i echo >> my commands to a text files and transfer them via floppy disk (yes, floppy diskettes, the USB prorts are locked down).
Reply With Quote
Reply

Tags
command substitution , df command , echo , shell scripting


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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 Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
UNIX / Linux echo command examples raj Getting started tutorials 8 15-11-2009 02:18 AM
echo command gr8linux Shell scripting 9 19-05-2009 04:22 AM
save command and command output savook CentOS / RHEL / Fedora 1 08-05-2009 05:33 PM
Execute UNIX Command / Shell Script Once In The Future permalac Shell scripting 2 27-08-2008 08:13 PM
displaying the executed command then echo the status warren Shell scripting 4 29-11-2006 01:56 AM


All times are GMT +5.5. The time now is 09:52 AM.


Powered by vBulletin® Version 3.8.5 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2010 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38