"ln -s" command to selected files

Advertisement

Prooksius
Guest

"ln -s" command to selected files

Hello!

Is it possible to do such a command:
Select needed files in the current directory and create symlinks for them with names the same as file names and extension - the last symbol = '0'.

For instance:
I mark following files

kjdj.doc
kdlkf.txt

Then I launch the magic command and in current directory I will have more two files:

kjdj.do0
kdlkf.tx0

which are symlinks to the first two files.

Thank you in advance.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: "ln -s" command to selected files

The "magic" custom command would be:
ln -s '!' `echo '!' | sed 's/.$/0/'`
Make sure you use right quotes. There are back-quotes around the "echo '!' | sed 's/.$/0/'"

Probably there is much better/simpler way how to achive the same results, but I'm not an expert in unix shell.

Reply with quote

Prooksius
Guest

Re: "ln -s" command to selected files

Thanks, but this command don't work with long file names with spaces.
Following command works fine:

ln -s '!' "`echo '!' | sed 's/.$/0/'`"

Just for somebody who needs this.

Reply with quote

Advertisement

You can post new topics in this forum