Tag Info

New answers tagged

1

I have no idea what the best approach is and elegance is certainly in the eye of the beholder, but I use the following for my dotfiles: A ~/.dotfiles directory that contains all of the dotfiles themselves. These are all managed in a git repo. A script, also in ~/.dotfiles that creates the required links into my home directory. I don't have any dotfiles in ...


2

The portable way to do this is with a case statement - and it doesn't hurt to trim the glob a little. for f in ~/common/.?*; do case $f in (*/..) ;; (*) : do something w/ "$f" esac done


5

Here is a method using bash's extglob: shopt -s extglob for f in .!(|.); do echo "$f" done With extglob the pattern !(pattern-list) matches anything except for the given pattern. The pattern in the example says match everything that starts with . and is not followed by nothing or another single ..


2

Using find find ~/common -type f -name ".*" -print0 | \ while read -d $'\0' file; do \ echo $file; \ done or with find and IFS find ~/common -type f -name ".*" -print0 | \ while IFS= read -rd '' file; \ do echo $file; \ done


0

.*[!.] for f in ~/common/.*[!.]; do echo $f done Will give you all .[...]foo but not . and .. Addition: Here's for excluding symlink files: for f in ~/common/.*[!.]; do [[ -L $f ]] || echo $f done .note: change || to && if you want to echo only symlink files.


1

You need to modify your glob pattern (currently *), probably you are looking for {[^.],.?}*, so for f in ~/common/.{[^.],.?}*; do echo "$f" done


1

Did you mean: ls -A also you can use ls -Al This wont list the . and .. (its the capital A that does that). a will list all, and A will list almost all, almost all cause . and .. arent listed. EDIT: The above is aimed at his second question, where he states he has the same issue with ls -a


-2

find . -maxdepth 1 -type f | while read f do ls -la "$f" done



Top 50 recent answers are included