Page 1 of 1 [ 5 posts ] 

hawk101
Emu Egg
Emu Egg

Joined: 14 Nov 2018
Gender: Male
Posts: 4

16 Nov 2018, 2:37 pm

Recently I've been learning a fair bit about commands and stuff in Linux, but also stumbled upon some difficulties on the way.

Basically, I have a quick question regarding the ls command - what would [aZ] mean? List both uppercase and lowercase letters ranging from a to z? Or specifically a and Z? I'm pretty sure it's my first assumption, but always better to check than to spend the next few months unsure.

I also have come across ls commands where the file written in the command ends with .t*t or even t*? - I didn't know this could be done with the end of a file? I thought there were only a limited and specific amount of characters used for the end of a file?

I've still got much to learn, but it's been very interesting and challenging. Hopefully there are others out there who are familiar with Linux, as well.



SpiceWolf
Veteran
Veteran

User avatar

Joined: 30 Jun 2008
Age: 47
Gender: Male
Posts: 802

16 Nov 2018, 6:00 pm

Assuming this is for awk.

Then as far as I remember [aZ] is a single character wild-card that matches either an 'a' or a 'Z'

To make it a range, you must put a dash in it like [a-z]
And mixing case might work(I've never tried it), but is ambiguous and therefore I do not advise it.

Better would be '/[a-zA-Z]'

or

'/[[:alpha:]]'

P.S. I would not consider myself to be a Linux expert, so use my advice at your own risk :)



hawk101
Emu Egg
Emu Egg

Joined: 14 Nov 2018
Gender: Male
Posts: 4

17 Nov 2018, 12:18 am

SpiceWolf wrote:
Assuming this is for awk.

Then as far as I remember [aZ] is a single character wild-card that matches either an 'a' or a 'Z'

To make it a range, you must put a dash in it like [a-z]
And mixing case might work(I've never tried it), but is ambiguous and therefore I do not advise it.

Better would be '/[a-zA-Z]'

or

'/[[:alpha:]]'

P.S. I would not consider myself to be a Linux expert, so use my advice at your own risk :)


Thanks for your input - was a bit thrown off as to why the command had "a" and "Z" in it, but without the "-", etc.. Would have thought it meant any letters of any case. Appreciated your thoughts and suggestions!

Any ideas on what the "*" and "?" in the file extension would do? Would it be the same as if it had been used for the start of the file (bring up a range of file endings depending on what characters are used)?



Trogluddite
Veteran
Veteran

User avatar

Joined: 2 Feb 2016
Age: 53
Gender: Male
Posts: 3,075
Location: Yorkshire, UK

18 Nov 2018, 12:56 pm

hawk101 wrote:
Any ideas on what the "*" and "?" in the file extension would do? Would it be the same as if it had been used for the start of the file

That's correct. When searching for a file, the file-system doesn't really care about root-names and extensions, it just treats the "dot" as it would any other character in the search string.


_________________
When you are fighting an invisible monster, first throw a bucket of paint over it.


hawk101
Emu Egg
Emu Egg

Joined: 14 Nov 2018
Gender: Male
Posts: 4

18 Nov 2018, 4:46 pm

Trogluddite wrote:
hawk101 wrote:
Any ideas on what the "*" and "?" in the file extension would do? Would it be the same as if it had been used for the start of the file

That's correct. When searching for a file, the file-system doesn't really care about root-names and extensions, it just treats the "dot" as it would any other character in the search string.


Okay, thanks!