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

StackOverflow https://stackoverflow.com/questions/21501671

  •  05-10-2022
  •  | 
  •  

Question

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

Was it helpful?

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top