i have some 1000 files in my dir and i want to find top 100 files and move them to some other location:
below the 2 commands i used, but it is not working
ls -ltr | grep ^- | head -100 | xargs mv destination - _________>not working
ls -ltr | grep ^- | head -100 | xargs mv {} destination- ___________>not working
-------------------------------------------------
plz help me in this?
can you please tell me how to implement this in my above commands
joeyg
September 16, 2008, 9:33am
4
The following shows how to do with a copy command
> ls
./ ../ file1 file2 moved/ psrf* psrf2* rawfile rawsorted
> cp `ls -ltr | grep "^-" | tail -2 | tr -s " " | cut -d " " -f9` moved
> ls moved
./ ../ file1 file2
So, you are going to want to do something lke
> mv `ls -ltr | grep ^- | head -100 | tr -s " " | cut -d " " -f9` destination
And if I thought long enough, I would bet there would be a way to accomplish with a find command also. The beauty of unix - many ways to approach and solve problems.