user1730357
user1730357

Reputation: 355

In Unix how do I list from 1 file name to another file name?

I need to list files from a specific file name until another specific file name. For example I have file1.txt, file2.txt, file3.txt, file4.txt, file5.txt if I wanted to start at file2.txt and end at file5.txt it should list the file names (not the content) file2.txt, file3.txt, file4.txt and file5.txt. Is there a way to do this using head and tail and if not what is a good way to do this?

Upvotes: 0

Views: 91

Answers (2)

user2317487
user2317487

Reputation:

ls -l | sort -n | grep -B1000 "file5.txt" 

Upvotes: 0

Beta
Beta

Reputation: 99134

ls | sort -n | sed '/file2/,/file5/!d'

Upvotes: 3

Related Questions