11 most important console teams for a developer

11 most important console teams for a developer

The command line greatly simplifies our life, allowing us to easily automate several routine tasks and increase the smoothness of the whole process. Instead of constantly clicking everywhere in the GUI, we can run a couple of commands and consider it done.

The Unix shell is a command line interpreter or, more simply, its interface, used in Unix systems and similar. The shell is both an interactive command and script language used by the operating system to control its operation with scripts.



Any operating system based on Linux or Mac has a default command line. Usually it is called “terminal”. The command line allows us to easily move and rename files, sort data and navigate.

Bottom there are 11 command line tricks that can make your life easier.

1. grep

$ grep “some string” file



The grep command searches for the specified templates in each file and those separated by newline characters, then prints all the lines that match these templates.

Использование grep для поиска всех ключевых слов React в файле.
Use grep to find all React keywords in the file.

The addition of option -i allows case insensitive search. In this case matches will be read out such words as “REACT”, “REact” and “react”.

$ grep -i “REact” file

With the value -c (count), we can find the number of lines that match the specified template/string type.

$ grep -c “react” index.js

Подсчитывание количества упоминаний слова “react” в файле.
Counting the number of references to the word “react” in the file.

Also note that the execution options for egrep and fgrep mean the same as for grep -E and grep -F, respectively. These are outdated variants used for backwards compatibility.

You can use grep for many more tasks. Detailed instructions for use are available here.

2. ls

$ ls

The ls command lists all files and directories located at the current specified path. If the file name acts as a path, ls displays information about this file according to the requested data. If the directory is used, the ls command displays information about the files and subdirectories it contains.

Применение команды ls для отображения всех файлов в текущей директории.
Application of ls command to display all files in the current directory.

You must have noticed that file names are displayed in gray and directories in blue. This helps us to distinguish them more easily.

3. pwd

$ pwd

Вывод пути текущей рабочей директории (pwd)

.

Path output of current working directory (pwd)

The pwd command is used to output the full system path of the current working directory. By default this command ignores symbolic links, although the full physical address of the directory can be displayed when the corresponding option is selected.

4. cat

$ cat somefile.js

Отображение содержимого файла посредством cat

.

Display the file contents by means of cat

.

The cat command has three possible functions in relation to text files:

  • This display.
  • Copy merge.
  • Create new.

The most common use of cat is reading the file content. It is the most convenient in this respect.

.

In the example below, the standard output cat is redirected to file2 by a redirect operator (it is represented as an angle bracket to the right of the command):

.

$ cat somefile > somefile2

Создание файлов посредством cat
Creation of files via cat

5. echo

$ echo “some text”

The echo command is used in Linux to display the text/string type string that serves as the argument. echo is a built-in command most commonly used in shell scripts and batch files to display system text on screen or in a file.

.

6. touch

$ touch somefile

The touch command is used to create an empty file. For example, it can be used when the user does not have data to store in the file at the time of its creation.

Создание нового файла посредством touch.
Create a new file by touch.

Note how touch is used to create the file, while cat is used to look inside the file. Since the newly created index2.js file is empty, cat does not display anything.

The main differences between cat and touch:

.

  • cat is used to create files with content.
  • touch creates empty files. Remember that the file created by the touch command is empty. This function is useful when there is no data to place in the file initially.

7. mkdir

$ mkdir some-directory

mkdir creates a new empty directory at the current location. Instead of clicking anywhere in the text editor or GUI for this purpose, just use this command:

.

Создание новой директории посредством mkdir.
Create a new directory using mkdir.

Note that we can look inside this directory with the command ls.

.

7.1 rm

$ rm someFile

Rm is applied for deletion and does its job 100%, to put it simply – finally deletes the file.

Удаление файла через команду rm
Delete file via command rm

By default this command does not remove the directory. However, it is possible if you add -rf.

 

$ rm -rf some-directory

Directory deletion via rm command (note that for this purpose we have added additional value -rf.

Bear in mind that in this case the whole directory including all its contents is deleted.

7.2 rmdir

$ rmdir some-directory

The rmdir command deletes the directory only when there is no content in it.

Удаление пустой директории через rmdir
Delete empty directory via rmdir

8. tail

$ tail somefile

The tail command reads the file and outputs the last part (the same “tail”).

Produce a certain number (-n) of last lines instead of 10 by default

This command can be very useful when considering failure reports or previous log history.

There is an example of its application when working with file logs.

9. wget

$ wget someurl

GNU Wget – free program to extract files using HTTP, HTTPS, FTP and FTPS (the most widely used Internet communication protocols). This command line tool is not interactive, so you can easily call it from scripts, CRON tasks, terminals without X-Windows support, etc.

Применение wget для извлечения информации о web-странице.
Application of wget to extract information about the web page.

GNU Wget has many tools to easily extract large files or mirror entire web/FTP sites.

Example:

  • Can resume cancelled downloads via REST and RANGE.
  • Can use file name templates and recursively mirror directories.
  • Supported work with NLS message files for different languages.
  • Can convert absolute references to uploaded documents into relative ones when needed, and then these documents can be referenced locally.
  • Runs on most UNIX and Microsoft Windows operating systems.
  • Supporting HTTPS proxy.
  • Supported HTTP cookies.
  • Supported persistent HTTP connections.
  • Can work in automatic or background mode.
  • It uses local file timestamps to determine whether to reload during mirroring.
  • GNU Wget is distributed under the license GNU General Public.
  • .

Other information can be found in of this product’s official documentation.

10. find

$ find path -name filename

The find command allows you to quickly find a file or directory. This is very convenient when working with large projects that contain hundreds of such elements.

Поиск всех файлов с именем index.js
Search all files named index.js

Search for specific file types

.

The find command also allows finding files of the same type in one directory (including subdirectories). For example, the following command will search for all .js files in the current working directory.

$ find . -name “*.js”

Search all .js files in the components directory

11. mv

$ mv somefile /to/some/other/path

The mv command moves files and directories from place to place. It supports moving them both individually and in groups.

Перемещение some-directory из директории components в каталог utils.
Moving some-directory from components to utils.

32 Views

0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments


Do NOT follow this link or you will be banned from the site!
0
Would love your thoughts, please comment.x
()
x

Spelling error report

The following text will be sent to our editors: