Skip to main content
Question Protected by Archemar
edited tags
Link
Gilles 'SO- stop being evil'
  • 865.3k
  • 205
  • 1.8k
  • 2.3k
Tweeted twitter.com/#!/StackUnix/status/49795246120374272
Source Link
Eugene Yarmash
  • 15.7k
  • 14
  • 54
  • 60

How can I read line by line from a variable in bash?

I have a variable which contains multiline output of a command. What's the most effecient way to read the output line by line from the variable?

For example:

jobs="$(jobs)"
if [ "$jobs" ]; then
    # read lines from $jobs
fi