Search code examples
shellls

Writing a shell script to obtain entries that contain a certain amount of integers?


I need help doing this I tried:

#!/bin/bash

ls -l [0-9][0-9]*

I am trying to get all the entries with 2 integers in them.

says ls cannot access no such file or directory


Solution

  • ls -l | awk '{print $9}' | grep '[0-9][0-9]'
    

    Or if you simply want to count them:

    ls -l | awk '{print $9}' | grep '[0-9][0-9]' | wc -l