This shows nothing in my directory. Why?
* a wildcard that will show everything?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
When it's in double quotes the
* doesn't get treated as a glob, and so doesn't get expanded. So you're asking
ls to list a file named
*, which probably doesn't exist.
To see all the files, you could run
ls without any arguments as it's default behavior is to show you all the files in the current directory. If you wanted to pass all the files as arguments to
ls for some reason, just remove the quotes so you run
but that's really similar to
except that if you have a lot of files
* might expand to pass too many arguments to
ls, and also
ls * will show the contents of directories while
ls by itself will just show that the directories are in the current directory without descending into them.
ls *.* /Dir (dir is optional)
lists every file(regardless of file type) in either the users current working directory (found by pwd) or in /Dir and
ls * /Dir (dir optional)
lists every file and directory one below in either the user's current working directory or in /Dir. However,
ls "*" & ls *.*
will not list recursively, for that you need
ls -R *.* /Dir
ls -R "*" /Dir
As for why
is not working correctly, you are correct: * is a wildcard, and when you call ls as so:
you are asking bash to find a file and/or directory that has an asterisk in its name. I had installed an IDE and could not find the configuration and main files for it, so I used these commands to find the files:
(found files matching the pattern and redirected them to a specific file)
locate *eclipse* >locate_eclipse.txt locate *tar* > locate_tar.txt locate *.tar* > locate_".tar".txt locate *compiler* > locate_compiler.txt locate *JRE* > locate_JRE.txt locate *jre* > locate_jre.txt
(Searched the whole filesystem and only prints the ones that match the pattern)
ls -R / | grep "eclipse" ls -R / | grep "tar" ls -R / | grep ".tar" ls -R / | grep "compiler" ls -R / | grep "JRE"
Sorry for the spiel, but I tried to cover most of the bases.