ln -s accept wildcards?


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users ln -s accept wildcards?
# 1  
Old 09-26-2011
ln -s accept wildcards?

Does ln -s accept wildcards? It doesn't seem like it is working when I use wildcards.
# 2  
Old 09-26-2011
It does work, but you need to be somewhere else (not in the directory you use it from, since on its own their's no chance to give the link another name):
Code:
$ touch a b c
$ mkdir d && cd d
$ ln -s ../*
$ ll
total 0
drwxr-xr-x    2 scott     wheel            256 Sep 26 11:52 .
drwxr-xr-x    3 scott     wheel            256 Sep 26 11:52 ..
lrwxrwxrwx    1 scott     wheel              4 Sep 26 11:52 a -> ../a
lrwxrwxrwx    1 scott     wheel              4 Sep 26 11:52 b -> ../b
lrwxrwxrwx    1 scott     wheel              4 Sep 26 11:52 c -> ../c

# 3  
Old 09-26-2011
Wildcards don't work inside the link. You can't create one link that will match several files.

The best you can do create multiple links like scottn demonstrates.
# 4  
Old 09-26-2011
Quote:
Originally Posted by Corona688
Wildcards don't work inside the link. You can't create one link that will match several files.

The best you can do create multiple links like scottn demonstrates.
This is what I tried. Is there a problem with this?

Code:
#!/bin/bash
echo "Downloading Java"
yum -y install wget
wget http://download.oracle.com/otn-pub/java/jdk/6u27-b07/jre-6u27-linux-i586-rpm.bin
echo "Making executable"
chmod a+x jre*
echo "Installing java"
./jre*
cd /usr/lib/mozilla/plugins
echo "Making symlink so Firefox works"
ln -s /usr/java/jre*/lib/i386/libnpjp2.so

# 5  
Old 09-26-2011
Quote:
Originally Posted by COKEDUDE
This is what I tried. Is there a problem with this?
There is one if /usr/java/jre* doesn't exactly resolves into one single directory when the command is executed.
# 6  
Old 09-26-2011
Code:
ln -s /usr/java/jre*/lib/i386/libnpjp2.so

Follow the logic for this.

If this resolves to one dir, you get ln -s /usr/java/jrewhatever/lib/i386/libnpjp2.so. It complains that you didn't give it a second filename to link to.

If this resolves to more than one, you're telling it to overwrite your other libnpjp2.so's with symlinks to the first one. Fortunately it won't as a safety feature.

I think what you want is:
Code:
ln -s /usr/java/default/lib/i386/libnpjp2.so /wherever/I/want/it/to/go.so

And you might only need to run it once, since /usr/java/default/ should point to the right place in any case.
# 7  
Old 09-26-2011
Quote:
Originally Posted by Corona688
If this resolves to one dir, you get ln -s /usr/java/jrewhatever/lib/i386/libnpjp2.so. It complains that you didn't give it a second filename to link to.
Actually not. "ln -s" destination is an optional argument and defaults to the current directory if unspecified.
This User Gave Thanks to jlliagre For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Renaming with wildcards

Hi, I'm new to Unix, but have a directory which has many files in it, well over 1000. The files are called : M07GO.STOPE0001 M07GO.STOPE0002 M07GO.STOPE0003 M07GO.STOPE0004 etc... I would like to rename them to the following : M070001.bin M070002.bin M070003.bin M070004.bin etc....... (4 Replies)
Discussion started by: rnmuk
4 Replies

2. Shell Programming and Scripting

Wildcards and exceptions

Hello: I have a very basic question. I'd like to select all files except for one file. For example, say I want to move all of the files in my current directory to a subdirectory called archive, I would use mv ./* archive/ But what if I want to move all files except for README.txt? Is there an... (19 Replies)
Discussion started by: Danny.Boy
19 Replies

3. UNIX for Dummies Questions & Answers

Help with rm command with wildcards

Hello everyone. My first time posting here. I have a question that may seem very insignificant to some but is one that I've been trying to address for the past several days (haven't had any luck looking online). I'm trying to clean a directory by removing old files that we no longer need.... (2 Replies)
Discussion started by: galileo1
2 Replies

4. Shell Programming and Scripting

figuring out wildcards

I'm trying to delete everything between ( and ) in a line, ie: ( start xxxx, end xxx ). there is uppercase, lowercase and numbers in the parans. and are of varied length. I tried this: sed 's/()//' infile > outfileI'm not understanding the wildcard use in brackets (2 Replies)
Discussion started by: dba_frog
2 Replies

5. UNIX for Advanced & Expert Users

Wildcards

These 2 websites do a GREAT job of explaining different types of wildcards. I learned about the categories of characters which I never knew about at all. GNU/Linux Command-Line Tools Guide - Wildcards GREP (1 Reply)
Discussion started by: cokedude
1 Replies

6. UNIX for Dummies Questions & Answers

wildcards NOT

Hi All Please excuse another straightforward question. When creating a tar archive from a directory I am attempting to use wildcards to eliminate certain filetypes (otherwise the archive gets too large). So I am looking for something along these lines. tar -cf archive.tar * <minus all *.rst... (5 Replies)
Discussion started by: C3000
5 Replies

7. Shell Programming and Scripting

wildcards with if statement?

Hello i am trying to use the wildcards with the if statement but it is displaying the error like this one if * | ** | * ] Any body can help me to for using the wild card option in the if case but i have used this code and working well with the case statement to enter the name without the... (14 Replies)
Discussion started by: murtaza
14 Replies

8. UNIX for Dummies Questions & Answers

ls with wildcards

ok, I'm trying to write a script file that lists files with specific elements in the name into a txt file, it looks like this ls s*.dat > file_names.txt can't figure out whats wrong with that line, any ideas? thanks in advance (10 Replies)
Discussion started by: benu302000
10 Replies

9. UNIX for Dummies Questions & Answers

wildcards

when writing a shell script (bourne) and using a unix command like 'ls' is there anything special you need to do to use a wildcard (like *)? (3 Replies)
Discussion started by: benu302000
3 Replies

10. UNIX for Dummies Questions & Answers

Wildcards in VI

I'm trying to delete lines from a large text file using VI. Every line that I am wanting to delete start with 'S' - all others do not. (A list of users) I've tried using * but doesn't seem to like it...any ideas... Doesn't have to be VI - but I'm better with VI than sed/awk. (8 Replies)
Discussion started by: peter.herlihy
8 Replies
Login or Register to Ask a Question