开发者

Flatten a java project directory structure prepending the path to the file

I am trying to write a script (preferably in bash) to flatten a java projet directory structure prepending the path to the file. Example:

| src
  | org
    | apache
      | file2.java
    | file1.java

would result in:

| src
  | org|apache|file2.java
  | org|file1.java

The script should be recursive since开发者_开发问答 the directory could have many subfolders.


cd src
for i in $(find . - name '*.java') ; do 
  echo cp \"$i\" $(echo "$i" | tr / _)
done

if it looks good(might barf if filenames contains spaces), pipe the result to sh

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜