LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 12-31-2003, 01:47 AM   #1
cxel91a
Member
 
Registered: May 2001
Posts: 61

Rep: Reputation: 15
BASH question


How can I redirect this information into a file at the command line?
df -h | awk '/\/dev\/hda3/ {print $5}'

I tried single quotes: echo 'df -h | awk '/\/dev\/hda3/ {print $5}' ' > bashscript
didn't work.

I tried double quotes: $echo "`df -h | awk '/\/dev\/hda3/ {print $5}' "> bashscript
didn't work

This is what I get for the file content. No options under man echo worked.

df -h | awk //dev/hda3/ {print }

Last edited by cxel91a; 12-31-2003 at 02:44 AM.
 
Old 12-31-2003, 02:48 AM   #2
fatgod
Member
 
Registered: Mar 2002
Location: Edinburgh, Scotland
Distribution: Suse 7.2, Gentoo 1.4, Solaris 9
Posts: 661

Rep: Reputation: 30
you need the "right" single quote... and here it is --> `
 
Old 12-31-2003, 03:02 AM   #3
cxel91a
Member
 
Registered: May 2001
Posts: 61

Original Poster
Rep: Reputation: 15
Tried that to. It will only put the output into the file.

Last edited by cxel91a; 12-31-2003 at 03:31 AM.
 
Old 12-31-2003, 03:09 AM   #4
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
Huh? I was reading this and thinking that's what you wanted. And fatgod's right:
Code:
echo `df -h | awk '/\/dev\/hda6/ {print $5}'` > foo
What do you want? The literal command in a file?
 
Old 12-31-2003, 03:30 AM   #5
cxel91a
Member
 
Registered: May 2001
Posts: 61

Original Poster
Rep: Reputation: 15
I want to get the commands typed on the command line into the file. Not the output of the command.
 
Old 12-31-2003, 03:34 AM   #6
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
If I understand what you're saying I have to wonder why not type them into the file directly? What was the problem? The '$5' disappearing? This seems to work:

Code:
echo "df -h | awk '/\/dev\/hda3/ {print \$5}'" > foo
 
Old 12-31-2003, 03:42 AM   #7
cxel91a
Member
 
Registered: May 2001
Posts: 61

Original Poster
Rep: Reputation: 15
thanks, for some strange reason I was getting 2 // before dev.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
A question about BASH operand Linux - Newbie 2 11-27-2005 09:49 PM
Bash Question mbjunior99 Programming 5 08-31-2005 04:33 AM
a bash question about while jiawj Linux - Newbie 3 07-14-2005 11:45 AM
bash question? shanenin Linux - Software 1 11-26-2004 12:22 PM
BASH question tpe Linux - Software 6 11-17-2004 08:59 PM


All times are GMT -5. The time now is 07:44 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration