here are some examples:
list all the files
$ ls
fileA fileAA fileAAA fileB fileBB fileBBB fileC fileCC fileCCC
fileA fileAA fileAAA fileB fileBB fileBBB fileC fileCC fileCCC
if you use * it will listed all files
$ ls *
fileA fileAA fileAAA fileB fileBB fileBBB fileC fileCC fileCCC
Read more...fileA fileAA fileAAA fileB fileBB fileBBB fileC fileCC fileCCC
but if using ? it will not
$ ls ?
ls: ?: No such file or directory
ls: ?: No such file or directory
list all files that start with file
$ ls file*
fileA fileAA fileAAA fileB fileBB fileBBB fileC fileCC fileCCC
fileA fileAA fileAAA fileB fileBB fileBBB fileC fileCC fileCCC
but if you use 1 ? it will listed only files that start with file+1 character
$ ls file?
fileA fileB fileC
fileA fileB fileC
same goes when you using 2 or 3 ?
$ ls file??
fileAA fileBB fileCC
$ ls file???
fileAAA fileBBB fileCCC
fileAA fileBB fileCC
$ ls file???
fileAAA fileBBB fileCCC
conclusion:
the asterix (*) is to replace zero to multiple characters while the question mark (?) only to replace a single character & of course you can use them with other commands as well such as find, grep etc...
No comments:
Post a Comment