Tag Archivio per: Line


This article explains how to find all files containing specific text on Linux. For this we’ll use grep, a standard Unix program.

grep is a command-line utility which prints lines that match a given pattern, and should be installed by default.

Let’s start simple. Say you want to search for the word text (case-sensitive!) in all the files in the current directory and its subdirectories. To do this, you need to open the terminal, navigate to the folder where you want to perform the search, and run:

grep -r 'text'

This lists all the files in the current folder and subfolders containing text. This includes strings like texting for example, because it contains our search pattern, text. -r stands for recursive, reading all the files in the directory and its subdirectories. If you require following all symbolic links, use -R instead of -r.

If you only want to list the filenames containing the exact whole word text (as opposed to the default partial word matching), and not things like texting, 123text, and so on, you’d need to append the -w (whole words) command line option, like this:

grep -rw 'text'

If you don’t want to search in the current folder, but in a specific folder, you can specify the path in which grep should look into, by adding it at the end of the command, like this:

grep -rw 'text' /path/to/search/into

You might also be interested in: How To Repeat A Command Every X Seconds On Linux

Grep has many options, but below I’ll only list a few that you might find especially useful when trying to find all files containing specific text on Linux (besides those already mentioned above):

  • -n shows the line numbers. When a match is found, besides the file path in which it was found, grep will also display the line number on which the pattern was found
  • -i performs the search case-insensitive (it’s case-sensitive by default). Depending on the number of files, this can slow down the search, so take this into consideration when using it
  • --include=GLOB / --exclude=GLOB includes or excludes certain files
  • --exclude-dir=GLOB is used to exclude folders from being searched

Let’s take a look at an example which combines these command line flags. Let’s say you want to find all files containing the case-insensitive (-i) text in the ~/Documents folder and its subfolders except for the Private e Personal subfolders (--exclude-dir), and only search in the files that have the .txt e .js extensions (--include). Also, you want to show the line numbers (-n), search recursively and also follow all symbolic links (-R). In that case, the command you’d need to use would be (this is a single command):

grep -Rni --exclude-dir={Private,Personal} --include={*.txt,*.js} 'text' ~/Documents

Example output:

/home/logix/Documents/test/folder/file1.js:7:text
/home/logix/Documents/test/folder/file2.txt:7:text

Here, 7 is the line number on which the pattern we’ve searched for (text) was found.

For more information and advanced usage, see the grep man page.

You may also want to check out ripgrep, a line-oriented search tool that recursively searches the current directory for a regex pattern that comes with some extra features, and is very fast.

You  might also like: rga: Search Text In PDF, Ebooks, Office Documents, Archives And More (ripgrep Wrapper) e How To Find Files Modified In The Last N Days Or Minutes Using find



In the following article, we will explain how to use the MATLAB function xline() to create enhiesto lines and insert them into a graph. These types of lines are often used as markers in graphs and charts. Therefore, we will also show you how to add text labels to these lines so that you can fully master this function in MATLAB. We have also included practical examples with code snippets and images in this article to better explain how you can create or draw enhiesto lines in this powerful programming environment for scientific computing. We also review the input arguments and data types accepted by xline(). We will also explain how to use each of these arguments to specify the desired attributes for the line you want to create.

MATLAB xline Function Syntax

xline ( x )
xline ( x, LineSpec )
xline ( x, LineSpec, labels )

Description and Examples for MATLAB Function xline()

The MATLAB function xline() creates and draws enhiesto lines at a specified point on the x-axis of a graph. It also provides the ability to place text labels and specify the format and attributes of the line color, width, linetype, etc. of the line being created. Next, we will look at each input argument for this function and explain the function each of them performs.

x: Specifies the coordinate of the “x” axis from which to draw the enhiesto line. This input accepts scalars and vectors to specify the coordinates.

LineSpec: specifies the style and color attributes of the line. The data type that LineSpec accepts is a character vector or string scalar.

Labels: enters the text labels we want to add to the enhiesto line. This input accepts strings and cell arrays of character vectors.

How to Create a Derecho Line with the xline() Function in MATLAB

In this example, we will show you the simplest way to create a enhiesto line with MATLAB’s xline() function. For this, we will first create an empty axis and enable the grid with the following functions:

Now, we will draw a enhiesto line on this axis. To do this, we call the function xline() sending in “x” the coordinate of the x-axis on which we want to draw the line. In this case, in the middle of the axis, we enter in “x ” the value 0.5. In this example, we use only the “x” input argument, so the line style parameters take the default values. Thus, the line drawn by xline() will be continuous and black. Next, we see the full code. With these functions, we have created the following empty graph:

In the following figure we see the line drawn from the x-axis:

How to Create Multiple Derecho Lines with MATLAB xline() Function

The input “x” to the MATLAB function xline() accepts scalars and vectors. So, it is possible to draw multiple lines by sending to “x” a vector with the coordinates of the multiple lines you want to draw. Next, we will see an example where we send a coordinate vector to draw10 equidistant enhiesto lines on a graph.

How to Set the Color Style and Linetype Using the LinSpec Input of the MATLAB Function xline()

When we draw enhiesto lines with xline(), we have the option to specify the type and color of that line. This is done using the input “LineSpec”. In this example, we will see how to select these attributes. The syntax of the “LineSpec” input for selecting the line style and color is as follows:

‘linetype color’  =  ‘- – g’  =  Dashed line green

Below is a table of the different line types and color options for the LineSpec.

Next, we will see the color options offered by the xline() function.

Now, we use the “LineSpec” input to create a enhiesto line of the dash-dot line type in red color on the same graph we created in the previous example, this time at coordinate 0.2 of the x-axis. To do this, we send the following string in the “LineSpec” input to set these attributes:

Below we can see the code for this.

The following figure shows how the line style and line color attributes can be specified with the LinSpec input of the MATLAB function xline().

How to Add Text Labels to the Derecho Lines of a Plot with MATLAB’s xline() Function

In this example, we show you how to add text labels to the enhiesto lines we create with the xline() function. These labels are sent as character strings at the time of the function call in the “label” input of xline(). We will now see an example of how we create a solid continuous blue line with the label “LinuxHint”. Next, we will see how the input arguments of the xline() function should be sent to create lines with text labels.

In cases where multiple lines of labels need to be created, we must first create a cell array of character vectors with each of these labels in the appropriate order and send this array to the “label” input of the xline() function as in the following example.

Conclusion

In this article, we showed you how to create and draw a enhiesto line on a graph using the MATLAB function xline(). We have described each of the input arguments in detail so that you can fully master this function. We have also included practical examples with image code snippets, showing how to set the style of the enhiesto lines and how to add text labels to them. We hope you found this MATLAB article helpful. See other Linux Hint articles for more tips and information.



Source link


A cascading style sheet is a piece of style code that is added to the HTML tags to enhance the work and appearance of HTML contents. Among many effects of CSS, one of the fundamental properties of styling the content is to apply a style sheet to the text, including text color, family, size, and location. One of the text properties of CSS will be explained in this article. This is an indent property. Indent means the displacement of the text from a certain point to a specific place.

Text Indent Property

While viewing some educational websites, you must have seen such paragraphs or text boxes that start with the first line from a distance of a whole paragraph, making it more prominent and appealing. This is done by making the first line of the text indented. Not only the first line, but we can also indent the second line keeping the first line intact. This text property is taken in either pixel or percentages. The syntax for the indentation of text is:

This property can be applied on any HTML content. However, now we will apply this property on the text. HTML and CSS both are the backbone languages for the front-end development and design of a webpage. HTML contains two basic sections: head and body sections. Both these portions are described with the tags:

All the HTML contents are described in the body sections. The head section contains the title of the webpage and the CSS if it is internal CSS. The basic HTML tags used in this article will be explained at the implementation time. Talking about the CSS declaration, we have used internal CSS among three CSS types. The CSS properties are declared inside the style tag, which is declared in the head tag.

There are several approaches to indenting the second line of the HTML paragraph. Some of the simple methods are explained below.

Example 1

First, we used an example to apply the CSS property of indent on a paragraph text of HTML. As the article’s name shows, we need to indent the second line of the text. In this example, we applied the indent property so that the first line of the paragraph remains the same at the point where it was before. However, the paragraph from the second line will be indented. Let us start with the example code. First, consider the body section, where a simple paragraph tag is used to apply the indent.

A simple heading is declared, which we will not apply any effect. The paragraph tag is declared inside the div. It is a container that keeps the HTML contents at a specific point. Similarly, here we will declare a div. A class is also declared here.

In CSS, the designing is done through the ids or the classes. All the effects we want to apply are written inside the class declaration in the CSS body. In the head portion, we need to mention the name at the point where we want to apply these effects.

Close all the tags and the HTML body as well. Merienda the HTML contents are declared, a single paragraph and a heading will be displayed when you run the page on the website. We will use the following CSS code to apply effects on this.

Heading toward the style tag, a div for the class is explained with the features we want to apply to this container. The text-indent of -36px is used, which means that the first line will not be indented. However, the first line is moved towards the left compared to the remaining paragraph lines. This is done by declaring the div’s left side padding 36px. Both the values are set in pixel units.

div.a {

text-indent: -36px;

padding-left: 36px; }

The padding property is for the inner content, which the outer one controls. This is the distance between the text boundary and the div container boundary. Now, save the code with the HTML extension and execute the webpage on the browser.

You will see a simple heading. A paragraph has the first line intact, but the second and all the other lines are shifted towards the right. The text-indent property of CSS does this.

Example 2

The text-indent property will be applied to the heading in this example. A simple heading is declared. After that, we used the paragraph tag to add text to it. The id in the div container will be applied to the whole div precisely in the same way. The effects described in the class were applied.

Inside the head section, a style tag will contain the id features. The div is given a margin and the width to be applied. The id is declared with a hash sign with it.

To apply effects on the paragraph specifically, we need to mention “p” with the id. The border above the paragraph is given with color and size. The padding-top effect is applied. This is the distance between the paragraph and the heading. The left two features are the text size and weight of the paragraph. This will be without the indented feature of the text. The heading is applied with the text-indent property of -26 pixels and padding the heading towards the left with the same value with a positive sign.

#container h2 {

Text-indent: -26px;

Padding-left: 26px;

}

Save the code and execute the file to examine the output.

On the execution, you will see that the heading is displayed so that the second line of the heading is indented towards the left direction. However, the first line remains the same.

Note: To make the second line of the text either in the paragraph or heading indented, we need to take the value of the text-indent in a negative direction. At the same time, the padding of the text should be done in the left direction with the positive value. The user should confirm that both these values should be the same. In both examples, we have applied the same concept.

Conclusion

The CSS indent property for the second line is an essential feature of text content that is applied to the paragraphs and headings to discriminate this text from others by making the text appealing to the user. Indent values can be taken in pixels and percentages as well. This property is applied to the paragraph’s first and second lines. The text-indent of the second line feature of CSS is accomplished by having the value with a negative sign and the same value for the padding with a positive sign. The padding direction should be taken as left. We have used two examples to elaborate on this text-indent concept that will be enough to enhance your knowledge regarding the text properties.



Source link


Often, you may need to convert or add the images to the PDF files, especially if you have an application and you want the users to download the images as PDF files.

There are different online tools that convert the images to PDF. But security is always a concern, and you can’t trust these online sites with your data. The best method is to convert the images on your machine. Linux offers various command-line utilities to aid you with that. The two common tools are Img2PDF and ImageMagick.

1. ImageMagick

ImageMagick stands out for the image conversion to PDF for its fast speed. The open-source Linux tool utilizes the multiple CPU threads to keep the conversion process fast. Whether converting one image or multiple images, ImageMagick gets the job done.

Let’s first install ImageMagick using the following command:

1
2
3

$ sudo apt update

$ sudo apt install -y imagemagick

For Fedora users, the command is as follows:

1

$ sudo dnf install imagemagick

With the ImageMagick already installed, navigate to the directory containing your pictures. We have different images in our example. We will see how we can convert them one by one and how to convert them all at merienda.

The syntax for conversion is as following:

1

$ convert image demo.pdf

Note that we are using convert, a utility for ImageMagick. Let’s start by converting one image.

If you run the previous convert command, it should work fine. However, you may end up with an error message like the one reflected in the following image:

In that case, all you need is to edit the policy.xml file using an editor like nano.

1

$ sudo nano /etc/ImageMagick-6/policy.xml

Look for the line in the following example:

1

<policy domain=«coder» rights=«none» pattern=«PDF» />

To fix the error, replace the rights from “none” to “read|write”

Save the file and rerun the command. You will now have a PDF file of the converted image.

To convert all the images in the current directory to PDF, you can add their names one by one or select the image format if they are the same. In our case, the image formats are in “.jpg”. In this case, our command is as follows:

That’s it! You now have all your images converted into one PDF.

ImageMagick is a great tool for converting the images to PDF on the command line. The only bad side of it is that the resolution for the images changes and the PDF file doesn’t have the full resolution, reducing the image quality.

 

2. Img2PDF

The ImageMagick converts the images to PDF, but the quality of the images reduces. The alternative is to use the Img2PDF to convert the same photos without losing the image quality. Besides, Img2PDF allows the specification of the image size when converting.

Start by installing Img2PDF using the following command:

1

$ sudo apt install img2pdf

You can verify the installation by checking the version.

Img2PDF can also be installed using pip in other distributions:

With the tool installed, let’s proceed to convert our images. We use the same pictures as we did with ImageMagick. First, navigate to the directory that contains your images. To convert a single file, use the following syntax:

1

$ img2pdf img -o converted.pdf

We now have a PDF version of the image. If you want to convert multiple images, you can list them all. Or if they have the same format, use the * shorthand like in the following example:

To specify the page size or the image size for the output, use the –imgsize or –pagesize.

For instance, to specify the image size to 30cm by 45cm, the command is:

1

$ img2pdf <image> –imgsize 30cmx45cm -o output.pdf

Conclusion

Converting the images of different formats to PDF shouldn’t trouble you when using Linux. There are command-line utilities at your disposal, and the syntax is easy. This guide has presented two utilities, Img2PDF and ImageMagick, that you can use to convert either one or multiple images to PDF.



Source link