cp , ln Commands to Create soft Links for all Files in Linux / Unix Directory


You can create soft links in Linux using cp and ln commands. Both commands will create soft links with –s option.
$ pwd
/home/oracle/test

$ ls -ltr
total 24
-rw-r--r-- 1 oracle oinstall  9703 Nov  4 01:14 vi
-rw-r--r-- 1 oracle oinstall 10307 Nov  4 01:40 ls.txt
$ mkdir test
$ cd test
$ pwd
/home/oracle/test/soft

cp command will omit directories.
$ cp -s /home/oracle/test/* .
cp: omitting directory `/home/oracle/test/soft'
$ ls -ltr
total 0
lrwxrwxrwx 1 oracle oinstall 21 Nov 21 05:58 vi -> /home/oracle/test/vi
lrwxrwxrwx 1 oracle oinstall 25 Nov 21 05:58 ls.txt -> /home/oracle/test/ls.txt

Using ln Command
$ ln -s /home/oracle/test/* .
$ ls -ltr
total 0
lrwxrwxrwx 1 oracle oinstall 21 Nov 21 06:08 vi -> /home/oracle/test/vi
lrwxrwxrwx 1 oracle oinstall 23 Nov 21 06:08 test -> /home/oracle/test/soft
lrwxrwxrwx 1 oracle oinstall 25 Nov 21 06:08 ls.txt -> /home/oracle/test/ls.txt
You can use unlink or rm command to remove the soft links.
$ unlink ls.txt
$ rm vi
$ ls -ltr
total 0
DBA Tips Data Pump Reference

0 comments:

Post a Comment

 

dba topics. Copyright 2011-16 All Rights Reserved | Site Map | Contact | Disclaimer | Google