Searching images with Googliser.sh in Mac: “ls: il

2019-09-14 06:40发布

问题:

I have a question over the script Googliser and the Mac commands.

I tried the script some days ago in the Mac shell and made it work. I followed the script listed here:

brew install wget
brew install gnu-getopt
brew link --force gnu-getopt
curl -sO https://raw.githubusercontent.com/teracow/googliser/master/googliser.sh
sed -i "" "s/readlink/stat/;s/dev\/shm/tmp/;s/p -p/p -t/" googliser.sh
chmod +x googliser.sh

Easy. It worked, not the first time, and I don't remember how I made it work. But then, I did my magic, and it stopped working.

The problem has something to do with the differences of the commands in the gnu terminal and the Darwin terminal. ln --I is not allowed in Darwin, but it is used, among others, in the script.

So everytime I try to run the script I get:

usage: ls [-ABCFGHLOPRSTUWabcdefghiklmnopqrstuwx1] [file ...]
ls: illegal option -- I
usage: ls [-ABCFGHLOPRSTUWabcdefghiklmnopqrstuwx1] [file ...]
ls: illegal option -- I
usage: ls [-ABCFGHLOPRSTUWabcdefghiklmnopqrstuwx1] [file ...]
       0/10 result groups downloaded. ls: illegal option -- I
usage: ls [-ABCFGHLOPRSTUWabcdefghiklmnopqrstuwx1] [file ...]
ls: illegal option -- I
usage: ls [-ABCFGHLOPRSTUWabcdefghiklmnopqrstuwx1] [file ...]
ls: illegal option -- I
usage: ls [-ABCFGHLOPRSTUWabcdefghiklmnopqrstuwx1] [file ...]
sed: 1: "/youtube/Id;/vimeo/Id;s ...": invalid command code I
No results!

I don't want to give up, because it worked. I tried to repair it installing coreutils and other packages to get the gnu commands, but no success. Maybe it has something to do as well with the .bash_profile file, now it is empty.

If I ask for a brew list it sais I have this installed. Very few things now, reinstalled everything again:

gettext     montage 
gnu-getopt  openssl     wget

I am missing something —sure I am, lots of things—. But, does somebody know why is this happening?

N.

回答1:

Ok, answer here: https://gist.github.com/dardo82/567eac882b678badfd097bae501b64e2/

#!/bin/sh

brew install      wget
brew install      ghostscript
brew install      coreutils
brew install      gnu-sed
brew install      gnu-getopt
brew link --force gnu-getopt

curl -O https://raw.githubusercontent.com/teracow/googliser\
\/master/googliser.sh

sed -i "" "s/readlink/greadlink/;\
       s/mktemp/gmktemp/;\
       s/head/ghead/;\
       s/ sed / gsed /g;\
       s/(du /(gdu /;\
       s/(ls /(gls /g;\
       s/dev\/shm/tmp/"\
     googliser.sh
chmod +x googliser.sh

And it works.

N.



标签: sh ls darwin