Question Unix - Changing directory from within a script

HikingLife

Junior Member
Jan 5, 2019
1
0
6
Hi,

This is a unix bash shell scripting question.

I have been trying to execute the below command by changing directory and then copying contents of one directory to another by doing some file name manipulations in between. However this isnt working since as soon as the statement completes it goes back to the original folder. Can someone help in telling me how to change a directory in a script so I can execute subsequent steps within it using and modifying a variable through the steps.

This fine works from command line, however gives bad substitution error from the script because of the issue explained above

for file in ABC/DEF/*.done; do file="${file%.*}"; file="${file##*.}"; cp "${file:0:31}"*.* /ABC/EDG/; done