You don't need piping, grep
or ls
. Just use shell globbing.
In bash
, using extglob
pattern (should be enabled by default in interactive sessions, if not do shopt -s extglob
to set it first):
file1@(|?|??)
?
matched any single character, @(||)
selects any of the patterns separated by |
.
If you only meant to match any characters between a-z
and A-Z
, use use character class [:alpha:]
which denotes all alphabetic characters in the current locale:
file1@(|[[:alpha:]]|[[:alpha:]][[:alpha:]])
Example:
$ ls -1
file1
file112
file11a
file12A2
file1a
file1ab
file1Ab
file1as
file2
fileadb
$ ls -1 file1@(|[[:alpha:]]|[[:alpha:]][[:alpha:]]))
file1
file1a
file1ab
file1Ab
file1as
zsh
supports this natively:
file1(|[[:alpha:]]|[[:alpha:]][[:alpha:]])
I am answering this portion very reluctantly, upon request from OP.
Any future reader, Don't parse ls
, use globbing.
Using ls
and grep
:
ls | grep -E '^file1[[:alpha:]]{,2}$'
Example:
% ls | grep -E '^file1[[:alpha:]]{,2}$'
file1
file1a
file1ab
file1Ab
file1as
You can try this
find -newerct "1 Sep 2016" ! -newerct "1 Oct 2016"
to see all files modified between 1th Sep 2016 to 1th Oct 2016. It works for find version equal or higher than 4.3.3
Here c
is the inode status change time. You can also use m
in place of it to have the result consider file modification time only.
Also the time string can be converted to YYYYMMDD
format. So, 1 Sep 2016
becomes 20160901
.
source: https://stackoverflow.com/a/23508622/1039893
Best Answer
You can use find:
Optional: To convert byte values to human-readable format, add this:
Explanation: