I wrote a little code that will copy files given either their name or symlinks to a given directory.
linkcp() {
cp `echo "$(realpath $1)"` "$2"
}
here is the file list:
$ ls -l
drwxr-xr-x 2 user1 users 4096 apr. 30 01:20 temp
-rw-r--r-- 1 user1 users 50 apr. 30 01:20 file1
-rw-r--r-- 1 user1 users 34 apr. 30 01:20 file2
lrwxrwxrwx 1 user1 users 26 apr. 30 01:20 lnk1 -> file1
lrwxrwxrwx 1 user1 users 26 apr. 30 01:20 lnk2 -> file2
This works if I use:
$ linkcp lnk1 temp
$ ls temp/
$ file1
but not if I use wildcards (I need to move all files beginning with lnk):
$ rm temp/*
$ linkcp lnk* temp
$ ls temp/
$
If I do:
$ arg=lnk*
$ cp `echo "$(realpath $arg)"` "temp/"
$ ls temp/
$ file1 file2
I don't know why using $1 in the function causes a problem?