How do I make a symlink to every directory in the current directory that has the same name but has u
- by Jason Baker
For instance, I suppose I have a directory that contains the following folders
foo_bar
baz
What I would like to have is a bash command that will make a symlink foo-bar to foo_bar so it would look like this:
foo-bar
foo_bar
baz
I'm pretty sure I can write a Python script to do this, but I'm curious if there's a way to do this with bash. Here's where I'm stuck:
ls -1 | grep _ | xargs -I {} ln -s {} `{} | sed 's/_/-/'`
What I'm trying to do is run the command ln -s with the first argument being the directory name and the second argument being that name passed through sed s/_/-/. Is there another way to do this?