Author: Arpit Mandliya
- 08 March
Convert String to Int in PowerShell
Using Dynamic Casting Use dynamic casting to convert the given string to int in PowerShell. [crayon-67699d93ad549647056965/] [crayon-67699d93ad54e013223644/] First, we created and initialized a $string variable; then, we specified the type as [int] before the string variable to do dynamic casting. In dynamic casting, we tell the compiler to think about things differently. To cross-check, we […]
- 07 March
Check if Command Exists in Bash
Use command Command Use command to check if the specified bash command exists. [crayon-67699d93ae9f9871711795/] [crayon-67699d93ae9ff539020911/] The command command is used to run a command bypassing any aliases or functions that may be defined. We can also use it to check if a command exists. In the above code, the if statement checks if the curl […]
- 07 March
Print Without Space in Python
Using the sep Parameter Use the sep parameter to print without space in Python. [crayon-67699d93aeb17426578886/] [crayon-67699d93aeb1a018793793/] Python’s print() method displays a specified message or variables’ value on the screen or other standard output devices. Here, the message means a string or an object or object that will be transformed into a string before writing to […]
- 07 March
Get Filename without Extension in Bash
TL;DR If you know extension of the file, you can use basename command and pass filename and extension as parameters to retrieve filename without extension in bash. This is useful when you have file extension like .tar.gz [crayon-67699d93aec42043954282/] [crayon-67699d93aec45896885396/] Using basename Command Use the basename command to get the filename without extension in Bash. [crayon-67699d93aec46084704318/] […]
- 07 March
Compare Contents of Two Folders in PowerShell
Comparing Contents of Two Folders in PowerSHell PowerShell is a powerful tool that can help system administrators and IT professionals automate routine tasks, and one of the common tasks is comparing the contents of two folders. This can be useful for identifying differences between two directory versions or finding missing files in a backup. To […]
- 07 March
Check if Array Contains Value in Bash
Using echo with grep Command To check if a Bash array contains a value, use the echo command and pipe it to grep command to search the value from the defined array. [crayon-67699d93af9f6211086174/] [crayon-67699d93af9fb003108834/] The value in the bash can also be checked with the grep command. We first declared an array named my_array that […]
- 07 March
String Comparison in Batch File
Comparing Strings in Batch File Batch files are a powerful tool for automating tasks in Windows systems. One common operation performed in batch files is string comparison. String comparison is used to determine if two strings are equal or not. This is useful when you need to perform different actions based on the value of […]
- 06 March
Check if Variable is Empty in Python
1. Introduction Checking if a variable is empty in Python is a fundamental task, especially in data validation or conditional logic. For example, in a user registration form, checking if the username field is empty is crucial before processing the form. Our goal to determine whether a variable like username contains any data or is […]
- 28 February
Check If Variable Is Empty in Bash
Checking If Variable Is Empty in Bash There are multiple ways to check if a variable is empty or not. Before moving towards those methods, knowing when a variable is called empty is necessary. In Bash, a variable is called empty if: A variable is declared without assigning any value to it. A variable is […]