Sunday, May 19, 2024
6
rated 0 times [  6] [ 0]  / answers: 1 / hits: 1171  / 2 Years ago, sat, june 4, 2022, 6:03:10

I want to list all ASCII files that are without extensions(.txt) in my present working directory(home).
I started with the ls command in the terminal but i don't know what i should put in the options as i want to list files that have no extensions but only a name.
How do i do it?


More From » command-line

 Answers
7

Run the following command:


find . -maxdepth 1 -type f ! -name "*.*" -exec grep -lvIP '[^[:ascii:]]' {} +


  • find is a more powerful ls.

  • . -maxdepth 1 means only the current directory

  • -type f means only files

  • ! -name "*.*" means excluding files with an extension

  • -exec grep...{} + means filter the list of files through the grep command

  • -lvIP '[^[:ascii:]]' means show only files -l which do not contain -v any non(^)-ascii characters, and also do not contain binary data(-I). Perl-syntax -P is required to use the [:ascii:] character class in the pattern.


[#1073] Monday, June 6, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
scusaper

Total Points: 335
Total Questions: 111
Total Answers: 119

Location: Belize
Member since Mon, Jun 20, 2022
2 Years ago
scusaper questions
Fri, Apr 15, 22, 15:26, 2 Years ago
Wed, Mar 15, 23, 03:53, 1 Year ago
Wed, Apr 6, 22, 00:55, 2 Years ago
;