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

advertisements

_____________________________________________________________________________________________________________________

The Eucharistic Miracles of the World

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

_____________________________________________________________________________________________________________________

Website Stats

0 comments:

Post a Comment

Labels

Oracle (629) Script (86) General (77) Unix (47) Blog (23) Technology (19) gadget (6) games (6) Business (3) OCI (3) SQL* Loader (3) Datapump (2)
 

acehints.com Copyright 2011-23 All Rights Reserved | Site Map | Contact | Disclaimer