how to get a informatin on a text files for my script

Hello

is a script bash

my part of code
 -v -T '848444' -r "link1" -a "link2" -f "WIN 13,0,0,182" -W "yes.swf" -p "http://yoyo.com" -y "mp4:$src" -o "$name.mp4"

Open in new window


exemple text files
<meta base="link.com/blablabla.mp4"/></head><body><video src="link.com/blablabla" /></body>

Open in new window


I want to get the links between "" "" and copy to my code

exemple 2
get this link on the text files  "link.com/blablabla.mp4" (link 1)  "link.com/blablabla"  (link 2)

-v -T '848444' -r "link.com/blablabla.mp4" -a "link.com/blablabla" -f "WIN 13,0,0,182" -W "yes.swf" -p "http://yoyo.com" -y "mp4:$src" -o "$name.mp4"

Open in new window


and copie link on my code  without the "

tx :)
GaaaraAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TintinCommented:
In the first example, where is the text file referenced?

In the second example, are links defined by the -a and -r arguments?
0
GaaaraAuthor Commented:
my code is an  example purposes only

I want to have that in between " " and copy in a  variable on my bash :)

exemple

is the text files

<meta base="link.com/blablabla.mp4"/></head><body><video src="link.com/blablabla" /></body> 

Open in new window


how to get information between " " on text files

and créate a variable on my bash

link1=link.com/blablabla.mp4
echo "$link1" 

link2=link.com/blablabla
echo "$link2"

Open in new window

0
woolmilkporcCommented:
Are there always exactly two quoted strings in the relevant line of the text file?
Do these lines always contain a unique keyword, like e. g. "meta"?
And, most important: Is there just one line in the textfile containing that keyword?

If so you can try this:

links=$(sed  -n '/meta/s/^.*"\(.*\)".*"\(.*\)".*$/\1 \2/p' textfile)
link1=${links% *}
link2=${links#* }
echo $link1
echo $link2

Alternatively, use awk. This will work even if there is just one quoted string, but we'll need a check to avoid link1 and link2 being the same in that case:

links=$(awk -F\" '/meta/ {if($4=="") $4="dummy"; print $2, $4}' textfile)
link1=${links% *}
link2=${links#* }
[[ $link2 = "dummy" ]] && unset link2
echo $link1
echo $link2

If there are (can be) several lines in the textfile containing the keyword and the links we must create a loop and work with arrays instead of single variables.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Learn Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

GaaaraAuthor Commented:
did not work

Are there always exactly two quoted strings in the relevant line of the text file?  yes
Do these lines always contain a unique keyword, like e. g. "meta"? yes
And, most important: Is there just one line in the textfile containing that keyword? no

links always changes just some word that does not change
link1 rtmpe: // does not change
link2 mp4 does not change

<smil><head><meta base="rtmpe://yoyo.com/vod"/></head><body><video src="JPMAK9ytVw3fzAxHuweyyeuw3743434kn3j4huyd67cuj3nr$$%fjudfyDWIe9XM2BElbQ74JZnAHm5RYe3EUm5J9AmZdpeJdK78VaGdw%3D-p%2BdQbrgVg7oqPMKmM16KQw%3D%3D.mp4?audioindex=0" /></body></smil>
0
woolmilkporcCommented:
Given the data you posted both of my scripts will show

for link1:
rtmpe://yoyo.com/vod

for link2:
PMAK9ytVw3fzAxHuweyyeuw3743434kn3j4huyd67cuj3nr$$%fjudfyDWIe9XM2BElbQ74JZnAHm5RYe3EUm5J9AmZdpeJdK78VaGdw%3D-p%2BdQbrgVg7oqPMKmM16KQw%3D%3D.mp4?audioindex=0

which exactly represents the two quoted strings which you asked to extract.

So why do you say "did not work" (apart from the fact that such a phrase is rude, at least extremely impolite)?
0
GaaaraAuthor Commented:
im so sorry ! it works

sorry I do not mean to be rude and it works I had made ​​a mistake

is a google translate and I do not speak english naturally
0
GaaaraAuthor Commented:
nikel
0
woolmilkporcCommented:
Merci a la pelle!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux OS Dev

From novice to tech pro — start learning today.