Files functions - mvaltas/grind GitHub Wiki

This set of functions aim to handle file operations like copying single files or whole directories. Files used by grind should be placed in a files directory inside the definitions directory.

file ORIG DEST

Will copy the file from GRIND_DEF_DIR/files/ORIG to DEST if DEST file does not exist.

file_force ORIG DEST

Will copy the file from GRIND_DEF_DIR/files/ORIG to DEST even if it already exists.

file_replace TARGET ASSOC_ARRAY

Will use ASSOC_ARRAY to replace tokens found in TARGET.

Example:

declare -Ax tokens=([NAME]='John' [AGE]='31')
file_replace "/path/to/my/file" tokens

dir ORIG DEST

Will copy all contents from GRIND_DEF_DIR/files/ORIG to DEST. ORIG and DEST must both be directories.

dir_force ORIG DEST

Will copy all contents from GRIND_DEF_DIR/files/ORIG to DEST overwriting existing files. ORIG and DEST must both be directories.

link ORIG DEST

Will create a soft link from GRIND_DEF_DIR/files/ORIG to DEST if DEST does not exist.

link_force ORIG DEST

Will create a soft link from GRIND_DEF_DIR/files/ORIG to DEST regardless if DEST already is a link or a file.