Find the answer to your Linux question:
Results 1 to 2 of 2
Any ideas as to why the CMD: " ls file[1-13] " ?? only lists " file1, file3 " but won't list " file2 or file13 " What would be the ...
  1. #1
    Just Joined!
    Join Date
    Jan 2011
    Posts
    4

    ls [brackets] question

    Any ideas as to why the CMD: "ls file[1-13]" ??

    only lists "file1, file3" but won't list "file2 or file13"

    What would be the correct syntax using brackets and hyphen to list all four files if you have:

    file1
    file2
    file3
    file13


    ??

    Thanks for your help.

  2. #2
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Location
    Harrow, UK
    Posts
    955
    Characters inside square brackets are treated as pure characters, not numbers. So [1-9] would match any of those nine digits, but ["13"] just means "either a 1 or a 3". So file2 does not display under these conditions.

    Using braces rather than brackets allows more variation. So for example ls file{1,2,3,10} would display file1, file2, file3 and file10. But I don't think you can use a range in this type of syntax.
    "I'm just a little old lady; don't try to dazzle me with jargon!"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...