Improve company productivity with a Business Account.Sign Up

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 282
  • Last Modified:

Unix/Linux basic script question

I am getting the unix command out put and sending into a file, but it is putting all the info in one line.

echo `/sbin/lltstat -nvv active` >> $LOG

What am I doing wrong?
8 Solutions
Trenton KnewOwner / Computer WhispererCommented:
the command you have there would write the literal string to the $LOG file.  I think you need to remove the "echo" from the command
Omit echo or use quotes:

/sbin/lltstat -nvv active >> $LOG

echo "`/sbin/lltstat -nvv active`" >> $LOG
Trenton KnewOwner / Computer WhispererCommented:
Just for clarification, are you trying to write the output of the lltstat command to a file?  $LOG is a variable, has it been defined?  echo '/sbin/lltstat -nvv active' will literally output "/sbin/lltstat -nvv active" to your $LOG file.
A proven path to a career in data science

At Springboard, we know how to get you a job in data science. With Springboard’s Data Science Career Track, you’ll master data science  with a curriculum built by industry experts. You’ll work on real projects, and get 1-on-1 mentorship from a data scientist.

@Trenton - please look a bit closer.  The asker uses backticks, not single quotes.
That's what we call "command substitution".
Trenton KnewOwner / Computer WhispererCommented:
ah, sorry... my bash skills are still developing.
Seth SimmonsSr. Systems AdministratorCommented:
$LOG is a variable, has it been defined?

if it wasn't defined, bash would have returned an ambiguous redirect
It looks like a line from shell script, not a BASIC script.
How the output of

/sbin/lltstat -nvv active | wc -l

looks like? Is it single line?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now