vendredi 2 février 2018

How do I do if on curl in shell script?

#!/bin/bash

NAME=$1

#curl -s https://instagram.com/$NAME/ | grep image | grep fbma | sed 's,s150x150/,,g' | cut -f 4 -d '"'

if [ s150x150 ]

then

curl -s https://instagram.com/$NAME/ | grep "og:image" | sed 's,s150x150/,s960x960,g' | sed 's,vp/,,g' | cut -f 4 -d '"'

else

curl -s https://instagram.com/$NAME/ | grep "og:image" | cut -f 4 -d '"'

fi

So as you see I have a shell script, and if my output contains "s150x150" I want it to sed vp/, but else I want it to dont do that. Problem is that it does always the if and even though it doesn't contain "s150x150". How do I solve this?

Aucun commentaire:

Enregistrer un commentaire