-1

My code for this is ls | grep .[0-9]*

And the output is showing as

d2
d4
di3
dir1
f1
f2
fil4
file3
g2t
g3t

The expected output is

d2
d4
f1
f2
g2t
g3t

I know i can directly use ls ?[0-9] but then my output order is different

f1  f2  g2t  g3t

d2:

d4:
jaco0646
  • 15,303
  • 7
  • 59
  • 83

3 Answers3

1

Okay this worked ls -d ?[0-9]*

0

This find command lists the files and directories in the current directory whose names have a second character that is a digit

find . -maxdepth 1 -name '?[0-9]*'
0

Try this , It will work

ls -1 | grep '^.[0-9][.]*'