开发者

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

开发者 https://www.devze.com 2023-01-03 04:05 出处:网络
I am trying to write a script (preferably in bash) to flatten a java projet directory structure prepending the path to the file. Example:

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

精彩评论

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