LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Blogs > linux-related notes
User Name
Password

Notices


Just annotations of little "how to's", so I know I can find how to do something I've already done when I need to do it again, in case I don't remember anymore, which is not unlikely. Hopefully they can be useful to others, but I can't guarantee that it will work, or that it won't even make things worse.
Old

Bash variables storing the output of commands run them at each variable statement, not just at some eventual invocation

Posted 08-10-2016 at 04:30 PM by the dsc (linux-related notes)
Updated 08-10-2016 at 04:33 PM by the dsc
Tags bash

Meaning that a script line such as:

nowstatus=`mpc | grep '#' | cut -d '/' -f1`

Is running mpc, grep and cut at its very statement, not only from an eventual "echo $nowstatus".

Therefore, in scripts that parse differently the same output of a given command, it may be preferable to first store this output in a temporary file, and then parse this file rather than running the same command several times. Such as in the lines added below their equivalent...
Member
Posted in Uncategorized
Views 1181 Comments 0 the dsc is offline

  



All times are GMT -5. The time now is 04:45 PM.

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