From: Greg Russell on
In news:43060fe9-03c7-464f-aab9-64adb8ed85fa(a)t34g2000prm.googlegroups.com,
Owen <xemoth(a)gmail.com> typed:

> 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?

mv -v *2010-03-23* sub


From: Glenn Jackman on
At 2010-03-23 11:20AM, "Greg Russell" wrote:
> From: "Greg Russell" <grussell(a)invalid.com>

Greg, you realize "invalid.com" is an actual domain, right?
You want "example.com" or "whatever.invalid"

--
Glenn Jackman
Write a wise saying and your name will live forever. -- Anonymous
From: Robert Latest 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?

Hello Owen,

you've already got some good answers on this one, but here's something I
find myself doing quite often: an ls | sed | sh pipe. Recently I had to
convert a bunch of files that had dates of the form DD.MM.YYYY in their
(otherwise quite random) names to easily sortable names like
file_YYYY-MM-DD.txt.

This is what I did: ls | sed -nr
's/.*([0-9]{2})\.([0-9]{2})\.([0-9]{4}).*/mv -i "\0"
file_\3-\2-\1.txt/p' | sh

(typed from memory, there might be syntax issues).

I also like to generate shell scripts using find's -printf directive.
Actually, find, sed and sh make an extremely powerful batch file
operation team.

robert
First  |  Prev  | 
Pages: 1 2
Prev: sed replace text Question
Next: FAQ faults