LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
LinkBack Search this Thread
Old 03-06-2008, 12:54 PM   #1
bartock
LQ Newbie
 
Registered: Feb 2008
Location: Planet Earth
Posts: 10

Rep: Reputation: 0
Question I have a shell scripting question


Hi;

When I run this snippet of script:


echo "/sbin/ifconfig | grep 'inet addr' | awk '{print $1, $2, $3}'" >> $STATSCRIPT

To $STATSCRIPT it writes :

/sbin/ifconfig | grep 'inet addr' | awk '{print , , }'

I know there is some escape sequences or something, but how can I get the $1,$2, etc to echo into my script. What am I forgetting??

G
 
Old 03-06-2008, 01:06 PM   #2
kaz2100
Senior Member
 
Registered: Apr 2005
Location: Penguin land, with apple, no gates
Distribution: Debian-woody->(testing) ->lenny->squeeze32/64-> wheezy(32/64)
Posts: 1,293

Rep: Reputation: 67
Hya,

Code:
echo `ls`
see what happens if you do above.

Happy Penguins!
 
Old 03-06-2008, 01:15 PM   #3
kilgoretrout
Senior Member
 
Registered: Oct 2003
Posts: 2,264

Rep: Reputation: 128Reputation: 128
I don't understand why you are using echo. Have you tried:

/sbin/ifconfig | grep 'inet addr' | awk '{print $1, $2, $3}' >> $STATSCRIPT

That should print $1, $2, and $3 and direct the output to $STATSCRIPT.
 
Old 03-06-2008, 01:41 PM   #4
bartock
LQ Newbie
 
Registered: Feb 2008
Location: Planet Earth
Posts: 10

Original Poster
Rep: Reputation: 0
Cool Clearer?

I guess I should be clearer - This line is part of a script that is going to be automatically run on multiple machines that are being deployed to the field - so, this is part of a script that is being put on the machine to be run.


Follow??
 
Old 03-06-2008, 02:37 PM   #5
Uncle_Theodore
Member
 
Registered: Dec 2007
Location: Charleston WV, USA
Distribution: Slackware 12.2, Arch Linux Amd64
Posts: 896

Rep: Reputation: 59
Quote:
Originally Posted by bartock View Post
I guess I should be clearer - This line is part of a script that is going to be automatically run on multiple machines that are being deployed to the field - so, this is part of a script that is being put on the machine to be run.


Follow??
It's still not clear, why you're using echo...
What exactly do you want to be written in your $STATSCRIPT file?
In other words, what is the desired output of this line in your script?
 
Old 03-06-2008, 02:46 PM   #6
forrestt
Senior Member
 
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288

Rep: Reputation: 98
OK, I'm not sure that was clearer, but somehow I think I know what you are asking. You don't want the $1, $2, and $3 values appended to $STATSCRIPT, you want to add a command to the end of $STATSCRIPT that when executed will output "$1 $2 $3".

I attempted a whole bunch of ways to escape things, but this is the only thing I could come up with:
Code:
echo "/sbin/ifconfig | grep 'inet addr' | awk '"'{print $1, $2, $3}'"'" >> $STATSCRIPT
HTH

Forrest
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
shell scripting question Komelore Linux - Software 3 03-12-2007 04:21 AM
shell scripting question creolophus Linux - Software 1 10-02-2006 02:13 AM
a shell-scripting question: mrchaos Slackware 3 09-22-2005 11:00 AM
Shell Scripting Question jester_69 Programming 13 11-05-2003 06:55 PM
Shell Scripting Question chrisk5527 Linux - General 12 07-09-2003 03:36 PM


All times are GMT -5. The time now is 11:32 PM.

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
Open Source Consulting | Domain Registration