Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Given a string like the following:

BASH - Mplayer Playlist Shuffle
BASH - Playing Music
BASH - Burn ISO images with cdrecord in Linux
BASH - replace space in file names

What would be the best way to get the titles, the URLs, and the uploaders into separate variables?

My thought was to find a way to grep, sed, or awk www.youtube.com, and then print the line above it or below it. Then save it into a variable. I haven't had any luck finding a solution that works.

share|improve this question
up vote 3 down vote accepted

Something like this:

$ while read -r title
> do
>  read -r url
>  read -r uploader
>  echo "Title is $title "
>  echo "Url is $url "
>  echo "Uploader is $uploader"
> done < file
share|improve this answer
What is the best way to accomplish the same thing, but using a variable instead of a file? Thanks for your response. – cadejscroggins Dec 28 '12 at 5:24
Just kidding, I believe <<< does the trick. Thanks again. – cadejscroggins Dec 28 '12 at 5:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.