diff --git a/site/pages/cmd/advanced/echo.html b/site/pages/cmd/advanced/echo.html index 04cc2ef..9da0e82 100644 --- a/site/pages/cmd/advanced/echo.html +++ b/site/pages/cmd/advanced/echo.html @@ -7,31 +7,18 @@ tags: echo calculator print title: echo --- +
+In computing, echo
is a command in Unix operating systems that outputs the
+strings it is being passed as arguments.
+It is a command typically used to output status text to the screen or a
+computer file, or as a source part of a pipeline.
+To use this simple command just type "echo" with the topic we want to
+print. The computer will return your argument as a string
-
-
-
In computing, echo is a command in Unix operating systems that outputs the
- strings it is being passed as arguments.
- It is a command typically used in
- shell scripts and batch files to output status text to the screen or a
- computer file, or as a source part of a pipeline.
To use this simple command just type "echo" with the topic we want to - print. The computer will return your argument as a string, for example, -
echo hello world
- will return hello world.
-
-
- echo 12+4 | bc
- will return 16.+echo "hello world" + hello world ++ diff --git a/site/pages/cmd/advanced/grep.html b/site/pages/cmd/advanced/grep.html index 1d906e7..c74d17d 100644 --- a/site/pages/cmd/advanced/grep.html +++ b/site/pages/cmd/advanced/grep.html @@ -3,11 +3,16 @@ layout: page author: Domenico Votta category-page: advanced category-title: Advanced commands -tags: search for occurences +tags: search for occurencies title: grep --- -
The grep
is a command that permits to search occurences of a keyword or more in a file or more. Through some flags you can decide the search criteria. The command grep is case sensitive (robot is different from Robot), but we will see how to ignore it
example1.txt
and example2.txt
that contain 5 elements, to test this command:
+The grep
is a command that permits to search occurences of a
+keyword or more in a file or more. Through some flags you can decide the search criteria.
+The command grep is case sensitive (robot is different from Robot), but we will see how
+to ignore it.
+
+Here we have two files named example1.txt
and
+example2.txt
that contain 5 elements, to test this command:
example1.txt
{% highlight bash linenos %}
@@ -31,50 +36,56 @@ The syntax command is:
grep [flag] [keyword] [file]You can put different flags together to refine the search. -{% highlight ruby linenos %} +
grep Robot example1.txt example2.txt (if you write robot you won't have the correspondence.) -example1.txt: Robot -example2.txt: Robot -{% endhighlight %} -+ +Your output will be this because grep found the keyword Robot in both filesYour output will be this because grep found the keyword Robot in both files
+ example1.txt: Robot + example2.txt: Robot +
Here a list that contains the main flags of these command: +Here a list that contains the main flags of these command:
grep -i robot example1.txt example2.txt -example1.txt: Robot -example2.txt: Robot + example1.txt: Robot + example2.txt: Robot+
grep -i -v robot example1.txt example2.txt -example1.txt:Car -example1.txt:Computer -example1.txt:Smartphone -example1.txt:Videogame -example2.txt:Apple -example2.txt:Computer -example2.txt:Microsoft -example2.txt:Huawei + example1.txt:Car + example1.txt:Computer + example1.txt:Smartphone + example1.txt:Videogame + example2.txt:Apple + example2.txt:Computer + example2.txt:Microsoft + example2.txt:Huawei+
grep -i -c robot example1.txt -1 + 1-
If in the file you would have had two times the keyword Robot, the output would have been 2
+ (If in the file you would have had two times the keyword Robot, the output would have been 2) +grep -i -h apple example1.txt example2.txt -Apple + Apple-
How you can see the output doesn't show tha file name example2.txt
example2.txt
+ The nl
is a command that permits to number the lines. Through some flags you can decide how to filter this command.
+The nl
is a command that permits to number the lines.
+Through some flags you can decide how to filter this command.
+
We have a file named example.txt
that contains 5 elements, to test this command:
+
{% highlight bash linenos %}
Car
Computer
@@ -21,49 +25,52 @@ The syntax command is:
nl example.txt - 1 Car - 2 Computer - 3 Robot - 4 Smartphone - 5 Videogame + 1 Car + 2 Computer + 3 Robot + 4 Smartphone + 5 Videogame-
How you can see the command has numbered the lines.
+ +How you can see the command has numbered the lines.Here a list that contains the main flags of these command:
nl -b p^[cv] example.txt - 1 Car - 2 Computer - 3 Videogame - Robot - Smartphone + 1 Car + 2 Computer + 3 Videogame + Robot + Smartphone-
p^[cv]
says to nl to number only the lines that start with c and v.
p^[cv]
says to nl to number only the lines that start with c and v.
+ nl -bn example.txt - Car - Computer - Videogame - Robot - Smartphone + Car + Computer + Videogame + Robot + Smartphone+
nl -s= example.txt - 1=Car - 2=Computer - 3=Videogame - 4=Robot - 5=Smartphone + 1=Car + 2=Computer + 3=Videogame + 4=Robot + 5=Smartphone+
The pipes
that in the shell are representend with the symbol | , they are used to join two commands on the terminal, taking the output of the first command and using it as input of the second.
It is usually common to see the command grep and ps together, an example below.
+
+The pipes
that in the shell are representend with the symbol | ,
+they are used to join two commands on the terminal, taking the output of the first
+command and using it as input of the second.
+It is usually common to see the command grep
and ps
together,
+an example below.
+Example: lists all processes with your username
ps aux | grep user-
Lists all processes with your username
+Example: count the lines of a file, using the +nl commandcat example1.txt | nl - 1 Car - 2 Computer - 3 Robot - 4 Smartphone - 5 Videogame + 1 Car + 2 Computer + 3 Robot + 4 Smartphone + 5 Videogame-
In this example you send this output to another process, in this case, the nl
-You can use the commands that you learned and put them together, always respecting the logic of the command.
+Example: passing expressions to bc +to do calculations ++echo "(12 / 2 - 3) * 3 + 1.5" | bc + 10.5 ++ +You can use the commands that you learned and put them together, always +respecting the logic of the command. diff --git a/site/pages/cmd/advanced/tr.html b/site/pages/cmd/advanced/tr.html index dd0825f..450ba2e 100644 --- a/site/pages/cmd/advanced/tr.html +++ b/site/pages/cmd/advanced/tr.html @@ -7,42 +7,49 @@ tags: translate title: tr --- +
+The tr
command in Unix-like operating systems, which name stands for
+TRanslate or TRansliterate, indicating its operation of replacing or removing
+specific characters in its input data set.
+
+
+tr 'abcd' 'jkmn' ++ +would maps all characters a to j, b to k, c to m, and d to n.
+tr 'a-d' 'jkmn' +- - -
tr is a command in Unix-like operating systems. It is an abbreviation of - translate or transliterate, indicating its operation of replacing or removing - specific characters in its input data set.
- -The utility reads a byte stream from its standard input and writes the - result to the standard output. As arguments, it takes two sets of - characters (generally of the same length), and replaces occurrences of - the characters in the first set with the corresponding elements from the - second set. For example, -
- - tr 'abcd' 'jkmn'
- maps all characters a to j, b to k, c to m, and d to n.
-The character set may be abbreviated by using character ranges. The - previous example could be written:
- -tr 'a-d' 'jkmn'- - -
tr -s '\n'- replaces sequences of one or more newline characters with a single - newline.
+tr -s '\n' ++ replaces sequences of one or more newline characters with a single + newline. +
tr -d '\r'-
+tr -d '\r' ++
+If you want to close the shell session, there are several ways to do so: -
If you want to close the shell session, all you have to do is press ^ (control) + D.
-Apply the change and save the session.
-After closing the session, the screen is still visible but the program does not allow you to type a new command.
-To continue using the shel all you need to do is quit the terminal and reopen the application
^ (control) + D
. Although this key combination closes the shell,
+ it doesn't quit the terminal application as it just saves and closes the current session.
+ A closed session does not allow any input or output anymore.
+ exit
command. Unlike the mentioned key combo, exit also quits
+ the terminal application itself.
+ g < ESC-<
:
+ g < ESC-<
:
Go to line N, by default 1, if N is not specified. G > ESC->
:
+ G > ESC->
:
Go to line N, by default the last one , if N is not specified. t
:
Go to the (N-th) next tag. open -t Desktop/text.txt -
The tool that allows us to interact with the system with the shell is the terminal. -There are mainly two ways to access to the terminal on a MacOS system.
+There are mainly two ways to access to the terminal on a MacOS system.
-Once the Terminal has been opened, a menu bar will appear exactly in the upper left corner of the screen.
-This menu contains some preferences that could improve the user experience and use of the Terminal.
+Once the MacOS Terminal app has been opened, a menu bar will appear exactly in the upper
+left corner of the screen. This menu contains some preferences that could improve the user
+experience and use of the Terminal.
The menu is divided into 6 sections that I will describe briefly to give you a basic knowledge
-that could be very useful once you have become familiar with the program.
+that could be very useful once you have become familiar with the program.
-
Inside the Terminal section you will find the item “secure Keyboard Entry”, this tool allows the user to enable an additional system security. - Essentially, this option prevents other Application from seeing what you are typing on the shell. - It also prevents processes that are working in background from monitoring your keystrokes. - In a first moment it seems that it doesn’t do anything, that’s because for people who works on their own personal computer, this additional secure becomes an unnecessary precaution. - However, this option could be very useful if you using an unknown computer or a public computer. -
Although Shell’s window does not occupy a lot of space, it is possible to hide the window by pressing ⌘ + H .
-In the other hand, it’s possible to hide all the others windows (except the Terminal) by pressing ⌥ + ⌘ + H .
-Once you have finished working with the Terminal, you can definitely close it by pressing ⌘ + Q .
-...
+⌘ + H
.
+ ⌥ + ⌘ + H
.
+ ⌘ + Q
.
+ It creates a new window
-It creates a new tab
-...
-This option close the window without quitting the terminal
-This option allows the user to customise the layout of the shell. This option contains some profiles that you can use instead of spending time to create your own one. - This option is not permanent, once the terminal has been quitted, the shell is set with the default settings.
-This options shows the inspector too, but it selects the current title that you want to change.
-This options shows some useful tools to customise the background of the shell.
-This option re-initializes the terminal. - /ref/
-This option re-initialize completely the terminal - /ref/
-This option allows the user to print only a selection of the shell. -The text must be selected by holding down the touchpad and then moving the mouse cursor.
-This options prints all the content of the shell
+...
-...
-Traditionally, the cut command was designed to move texts within applications, but, according to the Mac user community, it’s not very intuitive. - There is a much easier alternative way, the copy and paste, known as ⌘ + C (copy) and ⌘ + V (paste).
-It copies a selected text
-It copy a selected text by giving you more options. - For example, if you have a black background, copy special allows you to copy a selected file without considering the colour of the background.
-It paste a previously copied text.
-If you want to copy a text with special symbols, precisely code text, you have to use paste escaped text to maintain the text intact and not have characters interpreted as code.
-...
-It selects all the content of the shell.
-It select a portion of the text between marks
-Delete the last command and its content
-Delete all the content up to the start. - /ref/
-It delete all the not visible content.
-It delete all the visible content on the screen.
-It allows the user to find portions of text or words that matches with the inserted one.
+⌘ + C
(copy) and ⌘ + V
(paste).
+ It shows all tabs that you created, if no one has been created it will show only the current one.
-It shows you a tab bar with all the tabs created, this option is automatically enabled when you select “New Tab” under Shell section.
-. . .
-It creates an alternate screen.
-Disable the option “Show Alternate Screen”.
-It means that mouse clicks will be visible to whatever is reading the terminal, the position and click will be encoded and used by Text mode mouse-aware applications with standards permissions.
-It split every window in two windows
-It closes all the windows created with the command “Split pane”
-It set up default font size, if the size has been increased or decreased.
-It makes the font bigger.
-It makes the font smaller.
-Scroll to the top, at the start.
-Scroll to the bottom, at the end.
-It scroll up to the previous page.
-It scroll down to the next page.
-It scroll up to one line.
-It scroll down to one line.
-Full screen
- - +It reduces the terminal to an icon.
-It increases the size of the window. - By default the size is set up to 80 x 24.
-It switches between open windows.
-It shows previous tab, if created.
-It shows next tab, if created.
-It moves a tab to a new window.
-It takes all the windows and moves them to Tabs.
-It returns to default size of the window (80 x 24).
-...
- +It opens a useful guide that show you how familiarize with Terminal.
-Instead of digit man on the shell you can simply select the command and click on this option. - It will give you back an external manual page with all the descriptions.
- -