Bash Scripting: Build a bash script part 13
Command Line: Bash Scripting: Build a bash script: part 13

Regarding copy secreting but replace 42 with “XX”:
a. How do I modify the file that is being copied to “build/”

  1. Do I modify the file after the original file has been copied to build directory?

  2. Can I modify the file any other ways?
    For instance: here is my thoughts:

$file | sed ‘s/[0-9]/X/g’

But I do not know how to chain this command with ‘cp’ and copy the file with replaced contents into “build” directory. Can anyone suggest a good solution to chain commands to achieve this?


Hi vallajaz,

I have done this using the following commands:

if [ $file == "source/" ]
    sed "s/42/XX/" $file >> build/

Of course you can replace the regex string to support more than just the 42 like you’ve already done.

I hope this helps, and all the best,

1 Like