Re: [gentoo-user] look for a file type + sort

2013-09-14 Thread Florian Philipp
Am 14.09.2013 06:04, schrieb Mark David Dumlao:
 
 On Sep 13, 2013 9:53 PM, Yuri K. Shatroff yks-...@yandex.ru
 mailto:yks-...@yandex.ru wrote:

 On 13.09.2013 17:43, Mark David Dumlao wrote:

 On Fri, Sep 13, 2013 at 9:36 PM, Yuri K. Shatroff yks-...@yandex.ru
 mailto:yks-...@yandex.ru wrote:

 On 13.09.2013 10:24, Jean-Christophe Bach wrote:
 [ ... ]


 This one should work:

 find /home/joseph/ -iname *.pdf -exec ls -l --sort=time {} +



 -exec is not suitable here because it spawns a `ls` process per each
 found
 entry; aside from being slow, this disallows sorting at all.


 This is incorrect. If you terminate exec with '+' instead of '\;',
 only a single
 instance of the command is run - the command line is built by appending
 each found file to the end of the {} placeholder.


 Sorry, I'm ashamed
 I didn't know about this feature. Does it also handle spaces correctly?

 
 I'm not sure how the internals work. As best as I can guess, it
 constructs the argv directly so spaces shouldn't be an issue. Spaces are
 an issue when the output is piped through, since the pipe itself knows
 no difference between filename and output spaces, hence the need to
 force zero delimiters between filenames. Since find runs the command
 directly, you shouldn't encounter this. But Ive yet to test.
 

Your assumption is correct. exec cannot be fooled with whitespaces.

Regards,
Florian Philipp




signature.asc
Description: OpenPGP digital signature


Re: [gentoo-user] look for a file type + sort

2013-09-13 Thread Jean-Christophe Bach
* Canek Peláez Valdés can...@gmail.com [13.09.2013. @00:16:51 -0500]:

 On Fri, Sep 13, 2013 at 12:11 AM, Joseph syscon...@gmail.com wrote:
  On 09/13/13 00:04, Canek Peláez Valdés wrote:
 
  On Thu, Sep 12, 2013 at 11:58 PM, Canek Peláez Valdés can...@gmail.com
  wrote:
 
  On Thu, Sep 12, 2013 at 11:48 PM, Joseph syscon...@gmail.com wrote:
 
  I want to list recursively certain type of files eg. *.pdf but I want to
  display: date, path and newest file first.
 
  What is the easiest way of doing it?
 
 
  ls -l --sort=time $(find /path -iname *.pdf)
 
  If there are no spaces in the filenames/directories, you can drop the
  quotes from $().
 
 
  Sorry, it doesn't work with spaces even with the quotes; if you don't
  have spaces in the directories/filenames, do
 
  ls -l --sort=time $(find /path -iname *.pdf)
 
  If you have spaces, you need to set/restore IFS:
 
  S=${IFS}; IFS=$'\n'; ls -l --sort=time $(find . -iname *.pdf); IFS=${S}
 
  Regards.
  --
  Canek Peláez Valdés
  Posgrado en Ciencia e Ingeniería de la Computación
  Universidad Nacional Autónoma de México
 
 
  Hm, I've tried:
  ls -l --sort=time $(find /home/joseph -iname *.jpg)
 
  got:
  ls: invalid option -- '/'
 
 The exact same command (changing joseph with canek) works for me,
 except in directories/filenames with spaces, as expected. Do you have
 an alias for ls? What does find /home/joseph -iname *.jpg returns?
 
 Regards.
 -- 
 Canek Peláez Valdés

Hi,

This one should work:

find /home/joseph/ -iname *.pdf -exec ls -l --sort=time {} +

Regards,

JC


signature.asc
Description: Digital signature


Re: [gentoo-user] look for a file type + sort

2013-09-13 Thread Florian Philipp
Am 13.09.2013 08:24, schrieb Jean-Christophe Bach:
 * Canek Peláez Valdés can...@gmail.com [13.09.2013. @00:16:51 -0500]:
 
 On Fri, Sep 13, 2013 at 12:11 AM, Joseph syscon...@gmail.com wrote:
 On 09/13/13 00:04, Canek Peláez Valdés wrote:

 On Thu, Sep 12, 2013 at 11:58 PM, Canek Peláez Valdés can...@gmail.com
 wrote:

 On Thu, Sep 12, 2013 at 11:48 PM, Joseph syscon...@gmail.com wrote:

 I want to list recursively certain type of files eg. *.pdf but I want to
 display: date, path and newest file first.

 What is the easiest way of doing it?


 ls -l --sort=time $(find /path -iname *.pdf)

 If there are no spaces in the filenames/directories, you can drop the
 quotes from $().


 Sorry, it doesn't work with spaces even with the quotes; if you don't
 have spaces in the directories/filenames, do

 ls -l --sort=time $(find /path -iname *.pdf)

 If you have spaces, you need to set/restore IFS:

 S=${IFS}; IFS=$'\n'; ls -l --sort=time $(find . -iname *.pdf); IFS=${S}

 Regards.
 --
 Canek Peláez Valdés
 Posgrado en Ciencia e Ingeniería de la Computación
 Universidad Nacional Autónoma de México


 Hm, I've tried:
 ls -l --sort=time $(find /home/joseph -iname *.jpg)

 got:
 ls: invalid option -- '/'

 The exact same command (changing joseph with canek) works for me,
 except in directories/filenames with spaces, as expected. Do you have
 an alias for ls? What does find /home/joseph -iname *.jpg returns?

 Regards.
 -- 
 Canek Peláez Valdés
 
 Hi,
 
 This one should work:
 
 find /home/joseph/ -iname *.pdf -exec ls -l --sort=time {} +
 
 Regards,
 
 JC
 

This won't work if there are too many files because find will eventually
start ls multiple times.

Try this instead:
find /path -iname '*.pdf' -printf '%T@\t%Tc\t%p\n' | sort -nr |
cut -f 2-

Regards,
Florian Philipp




signature.asc
Description: OpenPGP digital signature


Re: [gentoo-user] look for a file type + sort

2013-09-13 Thread Joseph

On 09/13/13 08:50, Florian Philipp wrote:
[snip]


Hm, I've tried:
ls -l --sort=time $(find /home/joseph -iname *.jpg)

got:
ls: invalid option -- '/'


The exact same command (changing joseph with canek) works for me,
except in directories/filenames with spaces, as expected. Do you have
an alias for ls? What does find /home/joseph -iname *.jpg returns?

Regards.
--
Canek Peláez Valdés


Hi,

This one should work:

find /home/joseph/ -iname *.pdf -exec ls -l --sort=time {} +

Regards,

JC



This won't work if there are too many files because find will eventually
start ls multiple times.

Try this instead:
find /path -iname '*.pdf' -printf '%T@\t%Tc\t%p\n' | sort -nr |
cut -f 2-

Regards,
Florian Philipp


They both work thank you! 
But Florian solution seems to work better eg.


Solution 1:
find /home/joseph/ -iname *.jpg -exec ls -l --sort=time {} + |more
-rw-r--r-- 1 joseph users  113350 Aug 16 20:11 
/home/joseph/business/Drawings/tolsink_devices/Fostex-HP-P1_to_Ibasso-D12_2.6cm_c2c_69deg.jpg
-rw-r--r-- 1 joseph users  175335 Aug 14 17:16 
/home/joseph/business/Drawings/tolsink_devices/M8-AK120_3.4cm_c2c_32deg.jpg.jpg
...

Solution 2.
find /home/joseph -iname '*.jpg' -printf '%T@\t%Tc\t%p\n' | sort -nr | cut -f 
2- |more
Fri 30 Aug 2013 11:12:22 PM MDT /home/joseph/xp_share/img216.jpg
Tue 27 Aug 2013 05:18:56 PM MDT /home/joseph/Documents/albums/kuya_boy.jpg
Tue 27 Aug 2013 05:18:56 PM MDT /home/joseph/xp_share/kuya_boy.jpg
Tue 20 Aug 2013 10:31:29 PM MDT /home/joseph/0209C-SS_eyelets.jpg
Tue 20 Aug 2013 10:31:12 PM MDT /home/joseph/0210C.jpg
Fri 16 Aug 2013 08:11:59 PM MDT 
/home/joseph/business/Drawings/tolsink_devices/Fostex-HP-P1_to_Ibasso-D12_2.6cm_c2c_69deg.jpg
Wed 14 Aug 2013 05:16:13 PM MDT 
/home/joseph/business/Drawings/tolsink_devices/M8-AK120_3.4cm_c2c_32deg.jpg.jpg
...

The first solution did not find the first 5-files showing up in the Solution 2.

--
Joseph



Re: [gentoo-user] look for a file type + sort

2013-09-13 Thread Yuri K. Shatroff

On 13.09.2013 10:24, Jean-Christophe Bach wrote:
[ ... ]


This one should work:

find /home/joseph/ -iname *.pdf -exec ls -l --sort=time {} +


-exec is not suitable here because it spawns a `ls` process per each 
found entry; aside from being slow, this disallows sorting at all.

You'd prefer
find /home/joseph/ -iname *.pdf |xargs ls -l --sort=time

or, to be space-proof
find /home/joseph/ -iname *.pdf -print0 |xargs -0 ls -l --sort=time

A little late but HTH.
--
Best wishes,
Yuri K. Shatroff



Re: [gentoo-user] look for a file type + sort

2013-09-13 Thread Mark David Dumlao
On Fri, Sep 13, 2013 at 9:36 PM, Yuri K. Shatroff yks-...@yandex.ru wrote:
 On 13.09.2013 10:24, Jean-Christophe Bach wrote:
 [ ... ]


 This one should work:

 find /home/joseph/ -iname *.pdf -exec ls -l --sort=time {} +


 -exec is not suitable here because it spawns a `ls` process per each found
 entry; aside from being slow, this disallows sorting at all.

This is incorrect. If you terminate exec with '+' instead of '\;', only a single
instance of the command is run - the command line is built by appending
each found file to the end of the {} placeholder.

The only reason I see for it to fail is if you have so many files that
it can't be
passed to the argv of the receiving command.
-- 
This email is:[ ] actionable   [x] fyi[ ] social
Response needed:  [ ] yes  [x] up to you  [ ] no
Time-sensitive:   [ ] immediate[ ] soon   [x] none



Re: [gentoo-user] look for a file type + sort

2013-09-13 Thread Yuri K. Shatroff

On 13.09.2013 17:43, Mark David Dumlao wrote:

On Fri, Sep 13, 2013 at 9:36 PM, Yuri K. Shatroff yks-...@yandex.ru wrote:

On 13.09.2013 10:24, Jean-Christophe Bach wrote:
[ ... ]



This one should work:

find /home/joseph/ -iname *.pdf -exec ls -l --sort=time {} +



-exec is not suitable here because it spawns a `ls` process per each found
entry; aside from being slow, this disallows sorting at all.


This is incorrect. If you terminate exec with '+' instead of '\;', only a single
instance of the command is run - the command line is built by appending
each found file to the end of the {} placeholder.


Sorry, I'm ashamed
I didn't know about this feature. Does it also handle spaces correctly?


The only reason I see for it to fail is if you have so many files that
it can't be
passed to the argv of the receiving command.


There's always an opportunity to use tempfiles ;)


--
Best wishes,
Yuri K. Shatroff



Re: [gentoo-user] look for a file type + sort

2013-09-13 Thread Alexander Kapshuk

On 09/13/2013 07:48 AM, Joseph wrote:
I want to list recursively certain type of files eg. *.pdf but I want 
to display: date, path and newest file first.


What is the easiest way of doing it?


Perhaps not the most elegant solution.

ls -lt `du -a|grep -i '\.pdf$'|awk '{ print $2 }'`|awk '{ print 
$6,$7,$8,$9,$10,$11 }'





Re: [gentoo-user] look for a file type + sort

2013-09-13 Thread Mark David Dumlao
On Sep 13, 2013 9:53 PM, Yuri K. Shatroff yks-...@yandex.ru wrote:

 On 13.09.2013 17:43, Mark David Dumlao wrote:

 On Fri, Sep 13, 2013 at 9:36 PM, Yuri K. Shatroff yks-...@yandex.ru
wrote:

 On 13.09.2013 10:24, Jean-Christophe Bach wrote:
 [ ... ]


 This one should work:

 find /home/joseph/ -iname *.pdf -exec ls -l --sort=time {} +



 -exec is not suitable here because it spawns a `ls` process per each
found
 entry; aside from being slow, this disallows sorting at all.


 This is incorrect. If you terminate exec with '+' instead of '\;', only
a single
 instance of the command is run - the command line is built by appending
 each found file to the end of the {} placeholder.


 Sorry, I'm ashamed
 I didn't know about this feature. Does it also handle spaces correctly?


I'm not sure how the internals work. As best as I can guess, it constructs
the argv directly so spaces shouldn't be an issue. Spaces are an issue when
the output is piped through, since the pipe itself knows no difference
between filename and output spaces, hence the need to force zero delimiters
between filenames. Since find runs the command directly, you shouldn't
encounter this. But Ive yet to test.


 The only reason I see for it to fail is if you have so many files that
 it can't be
 passed to the argv of the receiving command.


 There's always an opportunity to use tempfiles ;)



 --
 Best wishes,
 Yuri K. Shatroff



[gentoo-user] look for a file type + sort

2013-09-12 Thread Joseph
I want to list recursively certain type of files eg. *.pdf 
but I want to display: date, path and newest file first.


What is the easiest way of doing it?

--
Joseph



Re: [gentoo-user] look for a file type + sort

2013-09-12 Thread Canek Peláez Valdés
On Thu, Sep 12, 2013 at 11:48 PM, Joseph syscon...@gmail.com wrote:
 I want to list recursively certain type of files eg. *.pdf but I want to
 display: date, path and newest file first.

 What is the easiest way of doing it?

ls -l --sort=time $(find /path -iname *.pdf)

If there are no spaces in the filenames/directories, you can drop the
quotes from $().

Regards.
-- 
Canek Peláez Valdés
Posgrado en Ciencia e Ingeniería de la Computación
Universidad Nacional Autónoma de México



Re: [gentoo-user] look for a file type + sort

2013-09-12 Thread Canek Peláez Valdés
On Thu, Sep 12, 2013 at 11:58 PM, Canek Peláez Valdés can...@gmail.com wrote:
 On Thu, Sep 12, 2013 at 11:48 PM, Joseph syscon...@gmail.com wrote:
 I want to list recursively certain type of files eg. *.pdf but I want to
 display: date, path and newest file first.

 What is the easiest way of doing it?

 ls -l --sort=time $(find /path -iname *.pdf)

 If there are no spaces in the filenames/directories, you can drop the
 quotes from $().

Sorry, it doesn't work with spaces even with the quotes; if you don't
have spaces in the directories/filenames, do

ls -l --sort=time $(find /path -iname *.pdf)

If you have spaces, you need to set/restore IFS:

S=${IFS}; IFS=$'\n'; ls -l --sort=time $(find . -iname *.pdf); IFS=${S}

Regards.
-- 
Canek Peláez Valdés
Posgrado en Ciencia e Ingeniería de la Computación
Universidad Nacional Autónoma de México



Re: [gentoo-user] look for a file type + sort

2013-09-12 Thread Joseph

On 09/13/13 00:04, Canek Peláez Valdés wrote:

On Thu, Sep 12, 2013 at 11:58 PM, Canek Peláez Valdés can...@gmail.com wrote:

On Thu, Sep 12, 2013 at 11:48 PM, Joseph syscon...@gmail.com wrote:

I want to list recursively certain type of files eg. *.pdf but I want to
display: date, path and newest file first.

What is the easiest way of doing it?


ls -l --sort=time $(find /path -iname *.pdf)

If there are no spaces in the filenames/directories, you can drop the
quotes from $().


Sorry, it doesn't work with spaces even with the quotes; if you don't
have spaces in the directories/filenames, do

ls -l --sort=time $(find /path -iname *.pdf)

If you have spaces, you need to set/restore IFS:

S=${IFS}; IFS=$'\n'; ls -l --sort=time $(find . -iname *.pdf); IFS=${S}

Regards.
--
Canek Peláez Valdés
Posgrado en Ciencia e Ingeniería de la Computación
Universidad Nacional Autónoma de México


Hm, I've tried:
ls -l --sort=time $(find /home/joseph -iname *.jpg)

got:
ls: invalid option -- '/'

--
Joseph



Re: [gentoo-user] look for a file type + sort

2013-09-12 Thread Canek Peláez Valdés
On Fri, Sep 13, 2013 at 12:11 AM, Joseph syscon...@gmail.com wrote:
 On 09/13/13 00:04, Canek Peláez Valdés wrote:

 On Thu, Sep 12, 2013 at 11:58 PM, Canek Peláez Valdés can...@gmail.com
 wrote:

 On Thu, Sep 12, 2013 at 11:48 PM, Joseph syscon...@gmail.com wrote:

 I want to list recursively certain type of files eg. *.pdf but I want to
 display: date, path and newest file first.

 What is the easiest way of doing it?


 ls -l --sort=time $(find /path -iname *.pdf)

 If there are no spaces in the filenames/directories, you can drop the
 quotes from $().


 Sorry, it doesn't work with spaces even with the quotes; if you don't
 have spaces in the directories/filenames, do

 ls -l --sort=time $(find /path -iname *.pdf)

 If you have spaces, you need to set/restore IFS:

 S=${IFS}; IFS=$'\n'; ls -l --sort=time $(find . -iname *.pdf); IFS=${S}

 Regards.
 --
 Canek Peláez Valdés
 Posgrado en Ciencia e Ingeniería de la Computación
 Universidad Nacional Autónoma de México


 Hm, I've tried:
 ls -l --sort=time $(find /home/joseph -iname *.jpg)

 got:
 ls: invalid option -- '/'

The exact same command (changing joseph with canek) works for me,
except in directories/filenames with spaces, as expected. Do you have
an alias for ls? What does find /home/joseph -iname *.jpg returns?

Regards.
-- 
Canek Peláez Valdés
Posgrado en Ciencia e Ingeniería de la Computación
Universidad Nacional Autónoma de México