Found 989 Articles for Software & Coding

How to create a Hash Table in PowerShell?

Chirag Nagrekar
Updated on 26-Feb-2020 10:09:07

1K+ Views

There are several ways to create a Hash Table in PowerShell. We will discuss here the standard method @{} for creating the Hash Table.Using @{} MethodYou can use @{} method to create a hash table. Key-Value pair is separated with the Semi-Colon (;). You can only add unique keys. Duplicate keys are not accepted.$htable = @{EmpName="Charlie";City="New York";EmpID="001"}OutputName       Value ----       ----- EmpID      001 City       New York EmpName    CharlieHere, you will not get the output in an ordered fashion. To get the ordered output, you need to write [Ordered] ahead ... Read More

What is Hash Table in PowerShell?

Chirag Nagrekar
Updated on 26-Feb-2020 10:06:13

275 Views

Hash table in a PowerShell is constructed with the Key-Value combination. Each key has its own value, so to get the value we need to refer the Key. We don’t need numeric indexing like Array to refer values.This is how the hash table looks like.Name       Value ----       ----- EmpName     Charlie City       New York EmpID       001In the hash table creation, keys and values are separated with Semi-colons (;). In the above example, EmpName, City and EmpID are referred as keys while Charlie, New York ... Read More

How to View Colored Man Pages in Linux?

Pradeep Elance
Updated on 25-Feb-2020 06:24:40

235 Views

The man pages are important reference pages for any Unix user. But their look and feel is very boring because it is just lines of text with some punctuations. In this article we will see how the different parts of the man pages can be coloured and highlighted. That will make it very easy to follow the instructions in the man pages.Using mostThe most command can be used to display the colour man pages but first we have to install it and then add to our bash profile so that it becomes available in the environment. The below command shows ... Read More

How to Show Asterisks While Typing Sudo Password in Linux?

Pradeep Elance
Updated on 25-Feb-2020 06:22:00

147 Views

When we use sudo along with a command, we are required to give the password in the next step. But when we start entering the password, we do not see anything displaying on the screen. The screen after the colon symbol remains blank. It creates a difficulty in knowing, how many characters we have entered. In thei article we will see how we can display asterisks for every character of the password entered.The below screen shows a command with sudo clause to copy a file. As you can see the screen asks for password but nothing is displayed when the ... Read More

How to Run a Command with Time Limit (Timeout) In Linux

Pradeep Elance
Updated on 25-Feb-2020 06:20:57

514 Views

Sometimes a Unix command may run for a very long time without giving the final output or it make a processing giving partial output from time to time. In such scenario we will like to put a time frame within which either the command mast complete for the process should abort. This is achieved by using below options.Using timeout ToolThe Timeout tool forces a command tour abort if it cannot complete within a given time frame. Below is the syntax and example.Syntaxtimeout DURATION COMMAND [ARG]... Where Duration is the number seconds you want the command to run Before aborting ... Read More

How to create an Animated Art on Your Linux Terminal?

Pradeep Elance
Updated on 25-Feb-2020 06:17:05

3K+ Views

Using the characters like - , / or | and many other from the keyboard, we can create animation characters. These characters can be static as well as moving in the screen. All this involves programming using shell scripting. These scripts are bundled into libraries or packages which can be installed in the terminal. Below we will see the examples of these animations.A Running TrainThis package produces a train animation when run from the terminal. But first we install it and then simple type sl in the terminal.$ sudo apt-get install sl $ slRunning the above code gives us the ... Read More

How to Change or Set System Locales in Linux

Pradeep Elance
Updated on 25-Feb-2020 06:00:00

2K+ Views

We often need to customise the operating system to become useful to our own preferences like the language we want to use the time zone we are in the type of currency which would become the default currency in the OS etc. In this article we will see how to customise these options which is known as locale.Current localeWe can check the current locally by using the locale command as shown below. We get list of variables which can be reset to a different value as per our choice later$ localeRunning the above code gives us the following result −LANG=en_US.UTF-8 ... Read More

How to create an array in PowerShell?

Chirag Nagrekar
Updated on 14-Feb-2020 06:41:14

2K+ Views

To create or declare an array in PowerShell, there are few methods.You can directly assign values to the variable and separate it by comma (, ) and that variable becomes the variable.For example, $a = "Apple", "Dog", "Cat", "Banana", "Camel"$a is now an array. To access the variable you can use the Indexing method. The first value will be stored at 0, second at 1 and so on.$a[0] will give the output “Apple”, $a[1] will give the output “Dog” and so on. Negative indexing also works in the array. -1 is the last index, -2 is the second last and ... Read More

What is Array in PowerShell?

Chirag Nagrekar
Updated on 14-Feb-2020 06:40:16

254 Views

An array is consists of a set of elements of the same data types or the different data types. When the output consists of more than one line then output or stored variable automatically becomes the Array. Its data type is Object[] or ArrayList and base type would be System.array or System.Object.For example, The output of IPConfig is an array.ExamplePS C:\WINDOWS\system32> ipconfig Windows IP Configuration Ethernet adapter Ethernet: Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . : Ethernet adapter VirtualBox Host-Only Network: Connection-specific DNS Suffix . : Link-local ... Read More

How to overwrite or remove PowerShell alias?

Chirag Nagrekar
Updated on 14-Feb-2020 07:58:30

4K+ Views

You can overwrite the Powershell alias by redefining it. For example, if the alias is created Edit for Notepad.exe and if you want to overwrite it with another program, say wordpad.exe then use the below command.We will overwrite the Edit alias cmdlet with Wordpad.exe using the Set-Alias command. When you close the PowerShell session, it will remove newly created aliases and modified aliases.Set-Alias edit "C:\Program Files\Windows NT\Accessories\wordpad.exe"You cannot overwrite pre-defined aliases. It will throw an exception.For example, when you try to modify dir alias which points to Get-Content, error output will be as below.To remove newly created aliases without closing ... Read More

Advertisements