0

I've a file which contains a list of remote files:

/trunk/a.java
/trunk/b.java
/tags/v1/a.java

I need to search a string into these files' contains. But they're remote file so I need to prefix them with a http:// part.

How can I do it ? I know cat and grep command but I don't know how to iterate over my file list, and concatains with a prefix...

  • By remote you say they are on a webserver only? Or do you also have ssh access? Is downloading them (e.g. via wget) an option? – Fiximan Aug 31 '15 at 8:47
  • @Fiximan Webserver, actually it's files managed by a svn server. – Fractaliste Aug 31 '15 at 8:52
  • Do you just need to know which files have the string or anything more? – Fiximan Aug 31 '15 at 9:00
  • @Fiximan just to know which files contain my string, then I'll access them with a subversion tool – Fractaliste Aug 31 '15 at 9:02
1

Assuming listoffiles is the file with the list of names, and they all start with / so you want to prefix with "http:/", and use curl, say, to get the file, you can do something simple like:

while read file
do    if curl "http:/$file" | grep 'my pattern'
  then svn ..."$file"...
  fi
done <listoffiles
  • 1
    I cannot reproduce the curl part. I would suggest if [[ $(wget -O /dev/stdout "http..$file" | grep 'string') ]] ; then – Fiximan Aug 31 '15 at 13:17
  • @Fiximan I used wget too – Fractaliste Sep 2 '15 at 9:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.