[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: moves dot files to different directory



> >ls -Ald ~/.??* | grep '^-' | sed 's/^\([^ ]*[ ]*\)\{8,8\}\([^ ]*\)/\2/'
> 
> ls -Ald ~/.[^.]* | grep '^-' | tr -s ' ' | cut -d' ' -f9
> It is not that much shorter, but it sure is prettier at least to my eyes. :)

Or if we are just trying to have fun with one line scripting...

  for i in $(echo '.*');do test -f $i && echo $i; done

And the output of the for...done loop can itself be used as input to
other commands.

  mv $(for i in $(echo '.*');do test -f $i && echo $i; done) /path/dir/

But that might trigger an ARG_MAX limit.  Better to use xargs.

  for i in $(echo '.*');do test -f $i && echo $i; done \
    | xargs --no-run-if-empty mv --target-directory /path/dir

Bob

Attachment: pgpnH6fLUnSPD.pgp
Description: PGP signature


Reply to: