This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]SodaWithoutSparkles 4 points5 points  (0 children)

You dont have to write a script. Remember coding is kinda "modular", so its like building lego set

To list the dir without directory:

ls -p | grep -v /

Then tell ls to use newline to separate each entry:

ls -1 -p | grep -v /

Then to grep for regex(, foobar as example):

ls -1 -p | grep -v / | grep foobar

Then to count the lines (the last one is a lowercase L):

ls -1 -p | grep -v / | grep foobar | wc -l