anomalous output from ls command

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read how to get help
Post Reply
Deus Absconditus
Level 1
Level 1
Posts: 38
Joined: Sat Aug 29, 2015 12:51 am

anomalous output from ls command

Post by Deus Absconditus » Sun Nov 18, 2018 12:00 am

when I do:
cd; sudo ls -aR | grep "prac*"
I get the following return:
prac2_question12
pracDirs
pracreport
Brush_Spraypaint.png
...
Can anyone explain the presence of the .png file here, which evidently does not contain the grep search string?

thx
Mint Cinnamon, 18

*************************************
Death takes no hostages,
and no holidays;
makes no deals,
no exceptions, and
offers no add-ons after delivery.
*************************************

User avatar
xenopeek
Level 24
Level 24
Posts: 23220
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: anomalous output from ls command

Post by xenopeek » Sun Nov 18, 2018 3:19 am

Yes, you've not read the regular expressions chapter of grep's manpage:

Code: Select all

   Repetition
       A regular expression may be followed by one of several repetition operators:
       […]
       *      The preceding item will be matched zero or more times.
So you're saying "find me a line that has the string pra followed by zero or more c's".

Remove the * from your grep pattern :)
Image

Deus Absconditus
Level 1
Level 1
Posts: 38
Joined: Sat Aug 29, 2015 12:51 am

Re: anomalous output from ls command

Post by Deus Absconditus » Sun Nov 18, 2018 5:26 am

Thank you kindly.
:D
Mint Cinnamon, 18

*************************************
Death takes no hostages,
and no holidays;
makes no deals,
no exceptions, and
offers no add-ons after delivery.
*************************************

Post Reply

Return to “Newbie Questions”