Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need some quick scripting help

Status
Not open for further replies.

proggybilly

Programmer
Apr 30, 2008
110
0
0
US
I need to place the results of ifconfig into a file, but seperating the interfaces. I can get the info into the file, but it runs it all together into one line. Can anyone help me to seperate the information?

I am doing:
Code:
THRU=`ifconfig`
echo $THRU > /backup/log.txt
 

try:
Code:
ifconfig > /backup/log.txt
[3eyes]


----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
Thanks, I tried that and it worked. Guess I was going about it wrong. I am still new to shell scripting.
 
proggybilly, Here at tek-tips we thank by awarding STARS.
 
With your backticks construct it can be done also, but you have to quote the echoed text:

Code:
THRU=`ifconfig`
echo [red]"[/red]$THRU[red]"[/red] > /backup/log.txt

And I always use the [tt][red]$(...)[/red][/tt] construct instead of the backticks because I find it easier to read. I also put braces [tt][red]{}[/red][/tt] around variable names when getting their value:

Code:
THRU=[red]$([/red]ifconfig[red])[/red]
echo [red]"[/red]$[red]{[/red]THRU[red]}"[/red] > /backup/log.txt


HTH,

p5wizard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top