0

I have the following file structure as an example

    c
    -Git
     -GitBranchTest
         .acignore
         [lots more files]
      -subfolder
         .acignore
         [lots more files]

I am trying to make a copy of all the .acignore files and rename to .gitignore, so when I am done it should look like this

    c
    -Git
     -GitBranchTest
         .acignore
         .gitignore
         [lots more files]
      -subfolder
         .acignore  
         .gitignore  
         [lots more files]

What I have tried and the error I got:

What I have tried

I hope this is clear enough. Please help.

2 Answers 2

1

This should do the trick:

find ./ -name '.acignore' | sed 's/.acignore//g' | xargs -I {} cp {}.acignore {}.gitignore

It's "./" if you are inside the "c" directory. If you are above it's "./c"

2
  • Thank you. I found another way to do it that is way more verbose. I still very new to bash shell scripting. Ive posted mine below, but will mark yours as the answer.
    – n4rzul
    Aug 14, 2020 at 15:33
  • Thx for upvoting :). Xargs is basically a foreach loop. That is why mine is one line. Aug 14, 2020 at 15:40
0

My attempt that works, but is very verbose :)

for i in  $(find /c/Git/GitBranchTest -name ".*" -print | grep acignore);do         
        from=$i
        replacement=.gitignore
        to=${from/.acignore/$replacement}
       echo "cp $from $to" | sh
done

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .