Skip to main content
added 103 characters in body
Source Link
Haukur
  • 189
  • 2
  • 3
  • 11

I have multiple hard drives with the same directory hierarchy, for example:

/media/sda/dir1 /media/sda/dir2 ... /media/sdb/dir1 /media/sdb/dir2 

Two hard drives with similar names and similar directory names. I want to create separate symbolic links to dir1 and dir2 on every hard drive. The easiest way I have found is to use cp -sR:

cp -sR /media/sd*/dir1 /somedir/dir1 cp -sR /media/sd*/dir2 /somedir/dir2 

However, this creates new directories in /somedir which has various side effects, for example, the directory timestamps are useless.

How can I create symbolic links named dir1 and dir2 which link to /media/sd*/dir1 and /media/sd*/dir2? Files are regularly added to the hard drives so I would need to run these commands on a regular basis.

I have multiple hard drives with the same directory hierarchy, for example:

/media/sda/dir1 /media/sda/dir2 ... /media/sdb/dir1 /media/sdb/dir2 

Two hard drives with similar names and similar directory names. I want to create separate symbolic links to dir1 and dir2 on every hard drive. The easiest way I have found is to use cp -sR:

cp -sR /media/sd*/dir1 /somedir/dir1 cp -sR /media/sd*/dir2 /somedir/dir2 

However, this creates new directories in /somedir which has various side effects, for example, the directory timestamps are useless.

How can I create symbolic links named dir1 and dir2 which link to /media/sd*/dir1 and /media/sd*/dir2?

I have multiple hard drives with the same directory hierarchy, for example:

/media/sda/dir1 /media/sda/dir2 ... /media/sdb/dir1 /media/sdb/dir2 

Two hard drives with similar names and similar directory names. I want to create separate symbolic links to dir1 and dir2 on every hard drive. The easiest way I have found is to use cp -sR:

cp -sR /media/sd*/dir1 /somedir/dir1 cp -sR /media/sd*/dir2 /somedir/dir2 

However, this creates new directories in /somedir which has various side effects, for example, the directory timestamps are useless.

How can I create symbolic links named dir1 and dir2 which link to /media/sd*/dir1 and /media/sd*/dir2? Files are regularly added to the hard drives so I would need to run these commands on a regular basis.

edited tags
Link
Haukur
  • 189
  • 2
  • 3
  • 11
Source Link
Haukur
  • 189
  • 2
  • 3
  • 11

Create symbolic links with wildcards

I have multiple hard drives with the same directory hierarchy, for example:

/media/sda/dir1 /media/sda/dir2 ... /media/sdb/dir1 /media/sdb/dir2 

Two hard drives with similar names and similar directory names. I want to create separate symbolic links to dir1 and dir2 on every hard drive. The easiest way I have found is to use cp -sR:

cp -sR /media/sd*/dir1 /somedir/dir1 cp -sR /media/sd*/dir2 /somedir/dir2 

However, this creates new directories in /somedir which has various side effects, for example, the directory timestamps are useless.

How can I create symbolic links named dir1 and dir2 which link to /media/sd*/dir1 and /media/sd*/dir2?