cmdchallenge icon indicating copy to clipboard operation
cmdchallenge copied to clipboard

files starting with u number does not accept valid solution

Open codesinthedark opened this issue 8 years ago • 2 comments

basename -a $(find . -type f) | grep ^[0-9] is not accepted as a solution but it outputs the same lines as accepted solution: ls -R|grep ^[0-9]|grep -v dir

Only difference that the lines are in different order and in the exercise it is not specified that we need a specific order. For example ls -U would not work because it traverses the files in directory order.

Also the accepted solution should not be accepted because if directories do not contain "dir" it would not work while basename -a $(find . -type f) | grep ^[0-9] would work.

Edit: not an issue

codesinthedark avatar Jul 05 '17 15:07 codesinthedark

It breaks on files with spaces so the failure is expected here:

bash(0)> basename -a $(find . -type f) 
42Robert
Hill
540Katherine
Jones
639Charles
Ferguson
593Brett
Martin
Mr.
James
Lopez
04Carrie
Alexander
132Rebecca
Rubio
477Thomas
Pierce
MD
388Andrew
Carter
335John
Joseph
974Michael
Bowman
48Thomas
Allen
Sheri
Bishop
737Jeffrey
Davis
Jorge
Ross
README
Matthew
Romero
293Linda
Bennett
436Teresa
Owens
78Michelle
Spencer
25Brandon
Mcdonald
provident.avi
99blanditiis.avi
sit.avi
nisi.avi
totam.avi
682Terri
Jones
778Holly
Archer
exercitationem.mp3
3maxime.mp3
402Nancy
Henson
757Robert
Marquez
511Tammy
Welch
670James
Jacobs
tmp

jarv avatar Jul 06 '17 06:07 jarv

You are correct. If I try find . -type f | while read fname; do basename "$fname" | grep ^[0-9]; done then it works :) Thank you 👍

codesinthedark avatar Jul 07 '17 12:07 codesinthedark