Looking For C’s in Shell
If you came here looking for tips on how to find seashell on the seashore, well… you’re probably going to be pretty disappointed. If you came here looking for a way to navigate to your C files in your shell, then you’re going to have a great time!
The person who will benefit most from the information in this post will be a novice, to intermediate novice, user on a UNIX-like system, like Linux! It is meant to explain to someone who is very new to using a CMI like shell. So, if that’s you, come right in!
So, first you may be want to know, what is “the shell”? The shell is a program that allows users to use the keyboard to enter commands to be read by the operating system. This used to be the only way things were done on UNIX-like systems like Linux.
Nowadays, there are graphic systems that we see through our eyes as a folders and files system. That has given users the chance to execute tasks outside of their command line interfaces (CMI). However, for the knowledgeable user, CMIs like shell, can be a powerful tool to perform specific tasks that just can’t be achieved on your everyday Graphic User Interfaces (GUI).
In order to interact with the shell, one must use a program called the terminal. This will bring up a window that allows the user to type commands in the shell that will interact with the system. In Windows, the terminal can be found by typing “cmd” in your search bar.
Like I said before, the shell can do some pretty powerful things, so I do not advise a novice user to operate the shell unless they understand whether they are operating as a SUPERUSER, because doing so may be dangerous and cause irreversible damage to your systems files.
Once in the shell, some version of this should appear (*note that my display settings have been modified):
Being inside the shell, is like being inside of a maze. However, there are navigation techniques that allow the user to easily find out where they are by executing some common commands like: cd, pwd, ls.
cd → change directory: used by itself, takes user to home directory. Allows navigation to other directories.
pwd → print working directory: shows user the path of the current directory
ls → list files and directories: shows user what’s in the current directory
These commands happen to be the same commands we use to list those C files I’ve been chirping about since the very beginning! :)
By typing the command cd, it will change the directory back to the home directory and you can verify you are there by typing pwd.
See example below:
From there, the user can go into their directory, in which their C projects have been saved, by entering the cd command followed by the name of the directory. For me, its C_Projects.
See example below:
Now that the correct directory has been called, the user can type in the command ls *.c and it’ll print a list of all the C files that are in that directory!
See example below:
There is a special shortcut being used in this command that is known as the “wildcard” (*) and it is very helpful when trying to find specific folders. The wildcard has the power to “ignore” parts of a filename when being searched and picking up where the text starts. In this case, we want to ignore the specific names of the file but as long as they have “.c” at the end, we want to see them!
This is just one thing that can be done while navigating through the shell, and the possibilities are limitless once discovering the power of different commands, which can be discovered right inside the man pages of the terminal. That’s for a whole new time, so for now have fun searching for your C’s in shell!.