给定一个如下所示的字符串:
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
将标题、URL 和上传者放入单独的变量中的最佳方法是什么?
我的想法是找到一种方法到grep
、sed
或awk
www.youtube.com,然后打印其上方或下方的行。然后将其保存到变量中。我没有运气找到有效的解决方案。
答案1
像这样的东西:
$ 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