If you are interested in getting a good grasp of command line, you will find this article describing the usage of the ls command very useful. Read this article to find out the opportunities offered by this command and how it should be properly used.
Viewing a long list of data
Another command you will find it handy is the dir/p. This p here stands for pause. This is to use when your dir command start listing a very long list of data on the screen and you are looking for something. In such a scenario, scrolling may become so inefficient.
With this command, you are able to view the list based on paging with the combination of spacebar key on your keyboard. Every time you are done with the page, press spacebar the next list will show up. For the macOS and Linux, use ls | more. This command gives you the same result. Notice that the symbol used here ( | ) is called a pipe. This is used a lot in the tech world. This tells the command line to take the next command after the pipe symbol and rather than directly sending it to the screen, pipe it. Just like a water pipe, the more you twist the knob the more water you get.
One of the strange behaviour you may notice at first is, if you put space between some command they work fine and for some they do not work. This is nothing strange but rather the command specific ground rule to obey, to make it work. This will get clear over time and use though.
With the dir command, typically you will see a row of date, time and filename and format, which specify the date and time of creation of the file. Another you will see is <DIR> followed by a name. This is to tell you that this is directory or a folder and the name followed by this DIR symbol. If you find the extra details to be distracting you can use dir/w and you will see the folder or filename only inside a square bracket laid out in columns and rows. To get all the possible switches on this dir command, call for the help and you will get the list of switches you can use with this command. Like, dir/?
The variety of –l switches
ls command, as for every UNIX based operating systems like mac and Linux, is one of the most powerful command which contains 50 various switches. You can have a look at multiple of these switches, for our purpose we are going to start with -l switch. This tells your system give you a long listing and detailed information of files. You will see a long list of names some of them won’t even make sense to you at this point, but do not worry about that. You will get a good a hang of that later. If you ever feel lost and cannot recall any certain commands, which is very common occurrence even with the experienced in the field, just simply type help in the command prompt and you will see a list of commands that you may find useful.
Notice that you are allowed to chain multiple switches together. Meaning, you can put multiple switches one after another but of course, start with the command first. For example on Linux, macOS try typing, ls-a-l-h and see what you get for this. You can also type like ls -alh and all three of these switches will be applied at the same time.