Say I have a folder with a series of symbolic links:ussdv103:en195d; default$  pwd/oradba/app/oracle/admin/database1ussdv103:en195d; default$  ls -ltrexp -> /oradba/app/oracle/acfsmounts/global/STREAM2a/database1/expdpdump -> /oradba/app/oracle/acfsmounts/global/STREAM2a/database1/dpdumpbackup -> /oradba/app/oracle/acfsmounts/global/STREAM2a/database1/backupThen I issue the following commmands to link it to a different STREAM directory:unlink $ORACLE_BASE/admin/database1/backupunlink $ORACLE_BASE/admin/database1/dpdumpunlink $ORACLE_BASE/admin/database1/expmkdir -p /oradba/app/oracle/acfsmounts/global/STREAM1a/database1/backupmkdir -p /oradba/app/oracle/acfsmounts/global/STREAM1a/database1/dpdumpmkdir -p /oradba/app/oracle/acfsmounts/global/STREAM1a/database1/expln -s $ORACLE_BASE/acfsmounts/global/STREAM1a/database1/backup $ORACLE_BASE/admin/database1/backupln -s $ORACLE_BASE/acfsmounts/global/STREAM1a/database1/dpdump $ORACLE_BASE/admin/database1/dpdumpln -s $ORACLE_BASE/acfsmounts/global/STREAM1a/database1/exp    $ORACLE_BASE/admin/database1/expThen I would use the following command to copy data from the old STREAM directory to the new STREAM directory:cp -p -r /oradba/app/oracle/acfsmounts/global/STREAM##/database1/ /oradba/app/oracle/acfsmounts/global/STREAM1a/.But I have to replace ## so that it reflects the location of the old STREAM directory, so the command will look like this:cp -p -r /oradba/app/oracle/acfsmounts/global/STREAM2a/database1/ /oradba/app/oracle/acfsmounts/global/STREAM1a/.How can I capture information about the old STREAM directory before unlinking it so that my copy command automatically replaces ## with the correct location of the old STREAM directory? Is there a Unix/Linux variable I can assign the old symbolic link to and then reference that in the copy command?
Capture symbolic link into Unix/Linux variables
linux;shell;symlink;variable
Store your old file destinations in a variable using the command readlink to read link information.OLDBACKUP=`readlink $ORACLE_BASE/admin/database1/backup`OLDDUMP=`readlink $ORACLE_BASE/admin/database1/backup`OLDEXP=`readlink $ORACLE_BASE/admin/database1/exp`NEWBACKUP=/oradba/app/oracle/acfsmounts/global/STREAM1a/database1/backupNEWDUMP=/oradba/app/oracle/acfsmounts/global/STREAM1a/database1/dpdumpNEWEXP=/oradba/app/oracle/acfsmounts/global/STREAM1a/database1/expunlink $ORACLE_BASE/admin/database1/backupunlink $ORACLE_BASE/admin/database1/dpdumpunlink $ORACLE_BASE/admin/database1/expmkdir -p $NEWBACKUPmkdir -p $NEWDUMPmkdir -p $NEWEXPln -s $NEWBACKUP $ORACLE_BASE/admin/database1/backupln -s $NEWDUMP $ORACLE_BASE/admin/database1/dpdumpln -s $NEWEXP    $ORACLE_BASE/admin/database1/expcp -p -r $OLDBACKUP $NEWBACKUPcp -p -r $OLDDUMP $NEWDUMPcp -p -r $OLDEXP $NEWEXP