From: Owen on
I just polluted a directory with 100 odd files, they were meant to go
into a sub directory. All files have a date so that ls -l|grep
'2010-03-23' list the files that need moving.

What one liner can I use to move them all into the sub directory in
one operation?


TIA


Owen

From: Laurianne Gardeux on
Owen à écrit :

> I just polluted a directory with 100 odd files, they were meant to go
> into a sub directory. All files have a date so that ls -l|grep
> '2010-03-23' list the files that need moving.
>
> What one liner can I use to move them all into the sub directory in one
> operation?
>
>
> TIA
>
>
> Owen

mkdir -p mysubdir; mv *2010-03-23* mysubdir
From: Tony Sequeira on
Owen wrote:
> I just polluted a directory with 100 odd files, they were meant to go
> into a sub directory. All files have a date so that ls -l|grep
> '2010-03-23' list the files that need moving.
>
> What one liner can I use to move them all into the sub directory in
> one operation?
>
>
> TIA
>
>
> Owen
>
Untested

cd dir

for OddFile in * ; do
echo mv $OddFile subdir/
done

Remove the echo when you see that it's going to work OK.

Disclaimer, if you have spaces or special characters in names of
files/directories, you will have problems with thui.
--
S. Anthony Sequeira
++
"They told me I was gullible ... and I believed them!"
++
From: Tony Sequeira on
Laurianne Gardeux wrote:
> Owen à écrit :
>
>> I just polluted a directory with 100 odd files, they were meant to go
>> into a sub directory. All files have a date so that ls -l|grep
>> '2010-03-23' list the files that need moving.
>>
>> What one liner can I use to move them all into the sub directory in one
>> operation?
>>
>>
>> TIA
>>
>>
>> Owen
>
> mkdir -p mysubdir; mv *2010-03-23* mysubdir

This is a better solution than mine, please ignore my loop.

--
S. Anthony Sequeira
++
Lackland's Laws:
(1) Never be first.
(2) Never be last.
(3) Never volunteer for anything
++
From: Ivan Shmakov on
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

>>>>> "O" == Owen <xemoth(a)gmail.com> writes:

O> I just polluted a directory with 100 odd files, they were meant to
O> go into a sub directory. All files have a date so that ls -l|grep
O> '2010-03-23' list the files that need moving.

O> What one liner can I use to move them all into the sub directory in
O> one operation?

Assuming GNU (Bash, Coreutils, Findutils), it could be:

$ find DIRECTORY/ -type f -mtime -1 \
-exec mv --target-directory=DIRECTORY/SUBDIRECTORY/ -- {} +

Depending on the context, it could just as well be ‘-mtime -2’,
or ‘-mtime -2 -mtime -1’, so adjust to the needs.

[...]

- --
FSF associate member #7257
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkuonCYACgkQaOzeitO4jPDspQCeJa4imRitjVA5Hd56JC/9ct5E
exIAoJj7RSlrIg/VXGWvvBDXX2y2x5wR
=ZxR0
-----END PGP SIGNATURE-----
 |  Next  |  Last
Pages: 1 2
Prev: sed replace text Question
Next: FAQ faults