Command-Line is an inexpensive tool for all developers since it helps to operate things smoothly by automating redundant tasks. Instead of playing a game of tag in the GUI, we can simply get the job done by running a few commands. Knowing some good terminal commands also helps developers need to maintain a good reputation online.
The Commands
Here are a few terminal commands to smoothen out your life:
1. grep
$ grep "some string" file
grep is one of the most useful commands that look for patterns in every individual file. Even if newline characters separate those patterns, grep can search and print each line with a match.
$ grep -i "REact" file
For searching strings, irrespective of case sensitivity, the -i option can be put to good use. That means the above command will match words with the same characters in that exact order whether they are capitalized or not. You will get matches like “REACT”, “react”, “reACT” and such similar results.
$ grep -c "react" index.js
Use the count flag(-c) to get the number of lines string match is found in a file.
2. pwd
$ pwd
This command comes handy for printing out the current directory of the full system path.
3. ls
$ ls
For finding out the list of directories and files in the current path, this command comes in great use. While listing the directories and files, your files appear in grey color while the folders appear in blue for quick and easy distinction.
4. cat
$ cat somefile.js
To quickly work with text files, the cat command is one of the best resources available. It allows you to see the contents of a text file, combine copies, or create new copies.
5. touch
$ touch somefile
With the touch command, you can quickly create an empty file with no content. It is useful when you need to plan ahead and create a file even when you don’t have any data to input at the time of the creation of that file.
If you run the cat command for a file created by touch command, it will return nothing.
6. tail
$ tail somefile
This command is pretty self-explanatory. It simply throws out the last part(“tail”) of a file after reading it. It especially comes in use when you need to go through history logs or crash reports.
7. mkdir
$ mkdir some-directory
You may have guessed this one as well by the name. Instead of searching through options in the GUI, use this command to quickly make an empty directory in the currently active path. To check the new directory, you can use the previously mentioned ls command.
Conclusion
We hope that with the addition of these console commands in your knowledge bank, it will help you to maintain a good reputation online as well as in the physical world. It will make your tasks a lot easier and you might end up ditching the GUI for the most part like your fellow developers.