Take the 2-minute tour ×
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.

Given a string like the following:

BASH - Mplayer Playlist Shuffle
http://www.youtube.com/watch?v=IB7SCPtbJM8
metalx1000
BASH - Playing Music
http://www.youtube.com/watch?v=S_-EGoLYCXY
metalx1000
BASH - Burn ISO images with cdrecord in Linux
http://www.youtube.com/watch?v=BxAEGa9NKs8
metalx1000
BASH - replace space in file names
http://www.youtube.com/watch?v=MRlUPV1221Y
metalx1000

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.