Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • is there a way to do it without the shopt -s extglob Commented Feb 9, 2016 at 22:36
  • 1
    (1) The first two commands can be improved by the addition of the -d option.  As written now, if you have a directory called dir.tx, then either of those commands will list the contents of dir.tx in addition to listing the text files.  -d will prevent that.  (2) -d will help the second command in another way.  Currently, if it is executed in a directory where there are no text (.txt or .tx) files, it will list all the files in the current directory.  With -d, it will just say .. … (Cont’d) Commented Aug 29, 2020 at 6:03
  • (Cont’d) …  (3) In the spirit of the first command, the find command can be shortened to find . -type f -regex '.*\.txt?' (assuming GNU find). Commented Aug 29, 2020 at 6:03