Aditya Chatterjee's Blog, page 103

March 22, 2022

Word Wrap Problem

In this article, we have solved the Word Wrap Problem in depth. This involves Dynamic Programming Concepts.

Table of contents:What is Word Wrap ProblemProblem StatementObjective of this problemWord wrap problem VS Word break problemLearn with a ProblemAlgorithm for Word Wrap ProblemComplexityWhat is Word Wrap Problem?

You are given ‘n’ words of various lengths, and a limit on the number of characters that can be put in one line (width of line: 'w'). Assume each word has length less ...

 •  0 comments  •  flag
Share on Twitter
Published on March 22, 2022 13:53

Different ways to delete string in C++

In this article, we have explored different ways to delete string in C++ which include clear, resize, erase, swap functions along with other techniques.

Table of contentWhat is a stringWays to delete a stringdelete operatorclear, resize, erase or swap functionsout of scopeWhat is a string

Before delete something we must understand what it is. So, what is a string ?
Well, that depends on the compiler you are using !

If you use the C compiler a string might look like this:

char *s =...
 •  0 comments  •  flag
Share on Twitter
Published on March 22, 2022 12:18

March 21, 2022

Hard and Soft file links in Linux

In Linux, everything is a file. We use links to access deeply nested files in a file system easily. We learn about soft and hard links in Linux, including how to create and remove them.

Table of contents.Introduction.Soft/symbolic links and hard links.ln command syntax.Creating symbolic links.Removing a symbolic link.Broken links.Summary.References.Introduction.

A link is a connection between a filename and the actual data stored on the disk. A link can either be hard or soft.
In this...

 •  0 comments  •  flag
Share on Twitter
Published on March 21, 2022 20:03

Globbing in Linux

Globbing involves bash interpreting glob characters to perform filename expansion of pattern searching in Linux. In this article, we will learn about globbing through various examples.

Table of contents.Introduction.Globbing patterns.Summary.References.Introduction.

Globbing is the process whereby bash interprets glob characters and performs file expansion or pattern matching.

When the shell finds a glob, it expands the pathname and extends the glob with matching file names.

Globbing patt...
 •  0 comments  •  flag
Share on Twitter
Published on March 21, 2022 19:51

file command in Linux

In Linux, we use the file command to determine the type of file. With this command we can know the type of file we are dealing with, this also includes compressed files and special files. In this article, we learn about this command using various examples.

Table of contents.Introduction.Syntax,Command usage.Summary.References.Introduction.

We use the file command in Linux to determine the type of file. We learn this command using various examples using commonly used options.

Syntax.

We w...

 •  0 comments  •  flag
Share on Twitter
Published on March 21, 2022 01:54

March 20, 2022

look command in Ubuntu

We use the look command to display lines in a file starting with a specified string. In this article, we learn about the look command through various examples.

Table of contents.Introduction.Syntax.Usage.Summary.References.Introduction.

In Linux, the look command is used to print lines in a file that start with a string. We pass this string to the look command.

This command uses linear search by default to search for the line starting with the string, however, if a file is not specified,...

 •  0 comments  •  flag
Share on Twitter
Published on March 20, 2022 04:31

ar command in Linux

As described in the manual page, the ar (archiver) command is used to create, modify, and extract from archives. In this article, we learn about this command through various examples.

Table of contents.Introduction.Syntax.Command usage.Summary.References.Introduction.

An archive is a collection of files with a common structure. We use the ar command to create, modify and extract individual files from an archive.

Syntax.

We write ar commands using the following format:

$ ar [OPTIONS] arch...
 •  0 comments  •  flag
Share on Twitter
Published on March 20, 2022 04:21

March 18, 2022

Aliases in Linux

Some commands in Linux are long and repetitive. Aliases enable us to make them shorter by mapping a long command to a shorter one. In this article, we discuss aliases in Linux.

Table of contents.Introduction.Listing aliases.Creating aliases.Creating permanent aliases.Deleting aliases.Multiple aliases.Summary.References.Introduction.

While working on the Linux command line, we sometimes write very long commands which are sometimes hard to remember. By using aliases we can create a shor...

 •  0 comments  •  flag
Share on Twitter
Published on March 18, 2022 15:47

xargs command in Linux

We use xargs to build an execution pipeline whereby we can send input to another command that does not accept piped input such as echo, mkdir, etc. In this article, we have learned the uses of xargs using various examples.

Table of contents.Introduction.Syntax.Usage.Summary.References.Introduction.

We use the xargs command to build an execution pipeline from the standard input. We use it in cases where we want to send input to a command that does not accept piped input. For example, comm...

 •  0 comments  •  flag
Share on Twitter
Published on March 18, 2022 15:30

March 17, 2022

tee command in Linux

The tee command reads standard input and writes it to standard output and a file or multiple files. We use it in cases where we want to send the output of a command to a file and at the same time want to print it out to the standard output. Let's discuss it.

Table of contents.Introduction.Syntax.Usage.Summary.References.Introduction.

The tee command reads standard input and can write it to a single file or multiple files including the standard output. Assume a scenario where we want to s...

 •  0 comments  •  flag
Share on Twitter
Published on March 17, 2022 14:13