creating multiple links with ln


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting creating multiple links with ln
# 1  
Old 06-14-2007
creating multiple links with ln

I want to make a symbolic link to a set of files in a particular directory if they exist. The number of files in the set is not known. The following script fails because it is ambigious.

if(-f dir1/*.a) then
ln -s dir1/*.a dir2/
endif

Can anyone help me?

Thanks a lot.
# 2  
Old 06-14-2007
cd dir1
for file_name in `ls *.a`
do
ln -s $file_name dir2/$file_name
done

Last edited by knowledge_gain; 06-14-2007 at 04:36 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script for creating symbolic links to my photos (*.JPG)

Hi, I have all my pictures as *.JPG and *.CR2 in the following folder structure: /media/a_2TB/pictures/year/year-month-day-hour/picture*.* But sometimes I added a subdirectory --> /media/a_2TB/pictures/year/year-month-day-hour/suba/picture*.*... (3 Replies)
Discussion started by: 8200
3 Replies

2. UNIX for Dummies Questions & Answers

can I create symbolic links for multiple files simultaneously

Does anybody know how to make symbolic links for multiple files simultaneously? Often times I need make symbolic links for multiple files with some common pattern (just like "*.jpg"). Is there a way to avoid making symbolic link for each of them one by one... Thank you! (6 Replies)
Discussion started by: danieladna
6 Replies

3. Programming

creating soft links

i'm trying to write a c code to copy a soft link over to a specified directory. Is it possible to do this without using symlink()? if so, what can I use? Thanks! (2 Replies)
Discussion started by: l flipboi l
2 Replies

4. Shell Programming and Scripting

SED multiple links in one line

I'm using sed to pull links from a rather large html file, and so far it's working rather well, but I've noticed that it is skipping some links. On some lines there are multiple links for example: It is completely skipping the first link in these. Here is what I'm using: sed 's/^.*<a... (4 Replies)
Discussion started by: DrMachin
4 Replies

5. UNIX for Advanced & Expert Users

Extracting files with multiple links-perl

i want to write a perl script that gets/displays all those files having multiple links (in current directory) (4 Replies)
Discussion started by: guptesanket
4 Replies

6. Shell Programming and Scripting

Creating tar excluding links

hi, How do i create a tar file of a directory excluding the links in that particular directory and its sub-directories. The below command doesnt work for me. tar -cvf abc.tar /dir1 --exclude"^l" (1 Reply)
Discussion started by: yesmani
1 Replies

7. Shell Programming and Scripting

Creating links to multiple folders

Hi All, First of all, I'm a unix newbie so don't be to hard on me :) I'm not even sure if the thing that I want is even possible but here goes nothing: On my linux based NAS I have the following structure: videos |---movie 1 |---movie 2 |---movie 3 | USBDISK |---videos |--- movie... (8 Replies)
Discussion started by: kvb
8 Replies

8. Solaris

Will creating symbolic links affect users

Hi, I have a quick question with regards to creating symbolic links. Would creating a symbolic link from one directory to a file in another cause any issues for users that are currently logged into the box. I don't believe it will unless they are using the file in question, but I would like... (2 Replies)
Discussion started by: Chains
2 Replies
Login or Register to Ask a Question