Re: moves dot files to different directory
On Fri, 28 Jun 2002 12:23:44 -0500, Derrick 'dman' Hudson wrote:
>On Fri, Jun 28, 2002 at 11:21:18AM -0500, Henning, Brian wrote:
>| hello all-
>| I have the task of moving all my hidden files to another directory. how can
>| i select only these files and not the standard files.
>|
>| ls .* doesn't seem to work.
>
>It does (but without "-a" you won't see them), but it includes '.' and
>'..' also :-) (you don't want to 'cp -r' those).
>
>
>ls -ad ~/.[^.]*
>
>
>(use -d to not get a recursive listing of all the directories)
^^^^^^
Thanks, dman. I'd never have thought of that. That took me to man ls
where I found -A. Even a blind pig can find an acorn now and then. :)
Excuse me if my comments only duplicate others', my ISP, bless their
numb-nut brains, is up to 30 hours delay in delivering the mail. Oddly
enough, I don't have the original post in this thread yet. :(
To ignore . and .., use -A (almost all). I also figured that
directories weren't needed, so grepped for regular files. Then used sed
to print only the 9th word.
ls -Ald ~/.??* | grep '^-' | sed 's/^\([^ ]*[ ]*\)\{8,8\}\([^ ]*\)/\2/'
I'm sure anyone with a clue will improve on this regexp (maybe use \< \>
for words?). I copied/modified this from a "RUTE" example.
Or, script the whole thing with awk.
#!/bin/bash
for i in $(ls -Ald ~/.[^.]* | grep '^-' | awk '{print $9}');
do
echo $i #test first
done
--
gt
It is interesting to note that as one evil empire (generic) fell,
another Evil Empire (tm) began its nefarious rise. -- gt
Coincidence? I think not.
--
To UNSUBSCRIBE, email to debian-user-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Reply to: