Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

find files that have number in file name greater than

Tags:

file

linux

ls

If I have 10 files called 01-a.txt, 02-a.txt,...10-a.txt - how can I find the files where the number is greater than 5? I would like a general solution, and I would be putting the contents of all files into one file using something like

cat *.txt > bigfile.txt

I can get files with numbers using

ls *[0-9]*

but can't seem go beyond that.

thanks.

like image 601
brucezepplin Avatar asked Mar 26 '15 14:03

brucezepplin


People also ask

How do I get a list of file names in a text file?

First, open the folder to obtain a file list within the Command Prompt. To do so, enter cd\ followed by a folder path and press Return. Press the Win + E key combo, and open the folder for which you set up a file title list. You'll find the file list text document you set up with the Command Prompt within that folder.


1 Answers

Assuming the folder contains only these files.

This would list all files where the number is > 5

ls [0-9]* | awk -F '-' '{if ($1 > 5) print $0}'

like image 86
dsri Avatar answered Oct 13 '22 06:10

dsri