This productivity tip, is how we can quickly create a new surrogate key file in Linux. This example is leveraging native capabilities of Red Hat Enterprise Linux (RHEL) to skip a few commands, by using an existing surrogate key file to create a new surrogate file with a minimum of keys strokes and command line entries.
Creating a New Surrogate Key File From an Existing File
The basic process consists of just a few steps:
- Navigate to the location of your existing surrogate key files
- Copy an existing surrogate file
- Empty the new surrogate key file
Navigate to the location of your existing surrogate key files
This step is preparatory step; you will need to look at the path variable for the project you are working with to know where to go. The actual path to the surrogate files your project can vary by project.
Copy an existing surrogate file
Assuming you have existing surrogate key files configured as needed, the use of the copy (cp) command can and the interactive and preserve options can eliminate the need to create the file, then set groups and permissions. The interactive (-i) option prevent you from overwriting any existing files, in case you made a filename typo and the preserver (-p) option preserve the specified attributes (e.g. ownership, and permissions).
- Here is the command formats with interactive and preserve, either format works
- cp -ip <<FileName to Be Copied>> <<New Filename>>
- Here is the command formats with only preserve
- cp -p <<FileName to Be Copied>> <<New Filename>>
- cp -ip srky blogexampl.srky
Empty the new surrogate key file
Setting the newly create surrogate key file to null will empty the file, so, DataStage can begin from the point configure in your DataStage job.
- cat /dev/null > <<FileName>>
- cat /dev/null > blogexample.srky