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

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

  •  05-10-2022
  •  | 
  •  

문제

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

도움이 되었습니까?

해결책

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top