9

There are some folder that contains space, and as a result, those folders can not be indexed using cscope.

Can i ask you for help to solve this,or any suggestion.

thanks Julius


Thanks for your reply.

My steps to use cscope like the following

  • find . -name '*.scala'>cscope.files
  • cscope -b
    at this step. i see the message indicates that can not find file:
    cscope: cannot find file /work/project/copy
    cscope: cannot find file of
    cscope: cannot find file fp/src/main/jav....
    Actually copy of fp is a folder.so i think cscope can not recognize the folder contains space.

I encountered this problem when i tried to use vim with cscope.maybe i need move this question to other tag.

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
julius
  • 91
  • 1
  • 3
  • 1
    You used the Vim tag. Is this because you are trying to use the `:cscope` commands within Vim? If so, can you show the commands that you are trying and what errors you are getting? – jamessan Jul 07 '10 at 16:46

4 Answers4

8

You can do it simply using GNU find at least, you can use the -printf or -fprintf options for that:

find . -type f -fprintf cscope.files '"%p"\n'
Olivier Diotte
  • 443
  • 3
  • 9
4

pydave's answer is very slow. This way took 0.10s where pydave's answer took 14s:

find . -name "*.scala" | awk '{print "\""$0"\""}' > cscope.files
webb
  • 4,180
  • 1
  • 17
  • 26
2

You can use find's -exec to force quotes around your output:

find . -name "*.scala" -exec echo \"{}\" \; > cscope.files

You might need to mess around with quoting/escaping if you're doing this from a script.

idbrii
  • 10,975
  • 5
  • 66
  • 107
  • This answer takes ~1 second to do ~100 files. My answer takes ~1 second to do ~100,000 files. – webb Mar 03 '16 at 16:03
  • 1
    @webb: Using fprintf (Olivier Diotte's answer) certainly seems like a better use of `find` than my naive proposal. – idbrii Apr 05 '16 at 17:37
0

Double quoting the files names works in cygwin, where as escaping with backslash does not.

$ find $PWD -name "*.scala" | sed -e 's/^/"/g' -e 's/$/"/g' > cscope.files
Talespin_Kit
  • 20,830
  • 29
  • 89
  • 135