Bash find, exclude parent?

I have a folder with some point files for which I would like to make symbolic links. I do not see an easy way to do this.

ls -a ~/dotfiles will include dotfiles, but also . and ..

find ~/dotfiles -maxdepth 1 will include dotfiles, but also ~/dotfiles

+7
source share
2 answers

Based on MvanGeests, the comment seems to work.

 find ~/dotfiles -maxdepth 1 -mindepth 1 

It also does the job.

 ls -A ~/dotfiles 
+13
source

It looks like you are trying to find point files, i.e. Files starting with "." and there is a second character that is not a ".". This should accomplish this task:

 find . -name '.[^.]*' 

to link all found files to / path / to / dir:

 find $PWD -name '.[^.]*' -exec ln -s '{}' /path/to/dir \; 

Note that "$ PWD" creates an absolute path, since symbolic links to relative paths most likely point to nirvana ...

+1
source

All Articles