Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Create Sym Links for a series of files Post 302941118 by Gussifinknottle on Monday 13th of April 2015 09:01:52 AM
Old 04-13-2015
Question Create Sym Links for a series of files

Hello,

I would like to create symbolic links for a series of files in my cwd (after confirming that the links don't already exist). The above files all have a similar prefix, but different extensions.

I created a shell script like shown below and I get an error message "No such file or directory"

Code:
#!/bin/sh

for x in `ls -1 /myRandomDir/myFiles.*`
do
    if [ ! -f $x ]
    then
        ln -s $x
    fi
done

What should I do differently.

Thanks!
~Guss
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

find and sym links

Would I be correct in assuming that find doesn't bother recursivley searching down sim links. (It doesn't seem to so I guess it doesn't!!!) Is there anyway to make it do so? (3 Replies)
Discussion started by: peter.herlihy
3 Replies

2. UNIX for Dummies Questions & Answers

How do I organize a series of files in date order?

I'd like to ls a group of files in date order but I'm not sure what the commands would be. Can anyone help with this? (1 Reply)
Discussion started by: hedgehog001
1 Replies

3. UNIX for Dummies Questions & Answers

rsync with --link-dest doesn't create hard links

I have been experimenting with rsync as a scriptable backup option, reading various example and tips pages, including Time Machine for every Unix out there - IMHO That page seems to describe the exact behavior I want: The ability to make a "full backup" snapshot regularly, but with rsync... (0 Replies)
Discussion started by: fitzwilliam
0 Replies

4. AIX

How to create a sym link pointing a changing name.

Hello A new file is created every day with the date appended to the end of a name. We are using Autosys to run jobs which watches for the file and runs jobs. But Autosys does not have the capability to figure out the current date. I tried creating a symlink like this ln -s... (1 Reply)
Discussion started by: vra5107
1 Replies

5. 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

6. Solaris

Create sym-link into /dev (zone)

Hi i need to install a software into a zone, and this kind of software needs to have a file who is linked into /dev. But it is not possible to create a link into /dev nor create a file into it. -bash-3.00# ln -s /tmp/testfile /dev/ ln: cannot create /dev//testfile: Permission denied... (2 Replies)
Discussion started by: beta17
2 Replies

7. Solaris

Hard Links and Soft or Sym links

When loooking at files in a directory using ls, how can I tell if I have a hard link or soft link? (11 Replies)
Discussion started by: Harleyrci
11 Replies

8. Shell Programming and Scripting

Create tar file excluding all hard links

I have a problem with tar. Taring a folder with a lot of contents, causes the tar to contain hard links to some files, seen with the same name but 0 in size. The hard links don't exist in the first place. How can I prevent that from happening? I am using the -T option with either -n or... (2 Replies)
Discussion started by: Tribe
2 Replies

9. Shell Programming and Scripting

Running a script over a series of files

Hi, I want to run a script over a series of files with the names : Sample_1.sorted.bam Sample_2.sorted.bam Sample_3.sorted.bam How can I specify it in my script. Thanks a lot in advance. (3 Replies)
Discussion started by: Homa
3 Replies

10. UNIX for Advanced & Expert Users

Find cmd and sym links

Hi. Can somebody tell me if there's a way of creating a symbolic link from a directory on one filesystem to that on another that will allow a find command that doesn't use the -L param to locate a particular file under that new 'linked' dir. With a normal sym link the find command on that... (6 Replies)
Discussion started by: user052009
6 Replies
LN(1)									FSF								     LN(1)

NAME
ln - make links between files SYNOPSIS
ln [OPTION]... TARGET [LINK_NAME] ln [OPTION]... TARGET... DIRECTORY ln [OPTION]... --target-directory=DIRECTORY TARGET... DESCRIPTION
Create a link to the specified TARGET with optional LINK_NAME. If LINK_NAME is omitted, a link with the same basename as the TARGET is created in the current directory. When using the second form with more than one TARGET, the last argument must be a directory; create links in DIRECTORY to each TARGET. Create hard links by default, symbolic links with --symbolic. When creating hard links, each TARGET must exist. Mandatory arguments to long options are mandatory for short options too. --backup[=CONTROL] make a backup of each existing destination file -b like --backup but does not accept an argument -d, -F, --directory hard link directories (super-user only) -f, --force remove existing destination files -n, --no-dereference treat destination that is a symlink to a directory as if it were a normal file -i, --interactive prompt whether to remove destinations -s, --symbolic make symbolic links instead of hard links -S, --suffix=SUFFIX override the usual backup suffix --target-directory=DIRECTORY specify the DIRECTORY in which to create the links -v, --verbose print name of each file before linking --help display this help and exit --version output version information and exit The backup suffix is `~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX. The version control method may be selected via the --backup option or through the VERSION_CONTROL environment variable. Here are the values: none, off never make backups (even if --backup is given) numbered, t make numbered backups existing, nil numbered if numbered backups exist, simple otherwise simple, never always make simple backups AUTHOR
Written by Mike Parker and David MacKenzie. REPORTING BUGS
Report bugs to <bug-coreutils@gnu.org>. COPYRIGHT
Copyright (C) 2002 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICU- LAR PURPOSE. SEE ALSO
The full documentation for ln is maintained as a Texinfo manual. If the info and ln programs are properly installed at your site, the com- mand info ln should give you access to the complete manual. ln (coreutils) 4.5.3 February 2003 LN(1)
All times are GMT -4. The time now is 06:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy