Computer Science, asked by deepdemta6478, 1 month ago

from what to what number File number ranges ?

Answers

Answered by anjalirehan04
0

I have a set of files in a directory numbered as follows:

file1.txt

file2.txt

...

file30.txt

...

Now, I'd like to run a command on a specific range of files, lets say 18 through 31.

So far I have used the following ways,

three arguments

command file1[8-9].txt file2[0-9].txt file3[0-1].txt

Now suppose I want every other number,

loop

for i in `jot - 18 31 2`; do echo file${i}.txt; done | xargs command

this seems like it's a more reliable loop (spaces work)

for i in `jot - 18 31 2`; do echo "\"file${i}.txt\" "; done | xargs command

but it seems like there should be a simpler way to do this. I am guessing the best solution is to create a bash function that will return the set of files to the command line. Then I could do something like,

command `filerange file 18 31`

please mark me brain mark list

Similar questions