Batch Script - Left String Last Updated : 19 Dec, 2021 Comments Improve Suggest changes Like Article Like Report In this article, we are going to study Left string in Batch Script. In Batch Script, the Left string is used to extract the characters from the beginning of the string by giving position 0 and a length using:~ while expanding a variable content. Example 1: Batch script set str=GeeksForGeeks echo.%str% set str=%str:~0,5% echo.%str% Output GeeksForGeeks Geeks In the above example, the key point you notice is :~0,5, which means that we need to display the characters starting from the position from 0 to 5. Example 2: Batch Script set str=Hello World echo.%str% set str=%str:~0,4% echo.%str% Output Hello World HellUsing the Cut commandCut command can also be used to extract the characters from the string that takes a few flags ( -cN-M ) as input and output the required substring. When you provide both variables i.e string and flag then it will return to you the characters in the string starting from index N and ending at M with both indexes included. Given below is an example of how to use the Cut command in Bash Batch script $ echo "GeeksForGeeks" | cut -c0-6 Output GeeksF Comment More infoAdvertise with us Next Article Batch Script - Left String H himanshubathla Follow Improve Article Tags : Linux-Unix Batch-script Similar Reads Batch Script - String length In this article , we are going to learn how to find length of any String using Batch Script. Batch Script :@echo off set str=Geeks For Geeks call :strLen str strlen echo String is %strlen% characters long pause exit /b :strLen setlocal enabledelayedexpansion :strLen_Loop if not "!%1:~%len%!"=="" set 2 min read Batch Script - Empty String In this article, we are going to create an Empty String using Batch Script. Batch Script :@echo off set str1= set str2=Hello ::using if statement we will check that str1 is empty string or not. if [%str1%]==[] echo "str1 is an empty string" if [%str2%]==[] echo "str2 is an empty string" pauseExplana 1 min read Batch Script - Create String In this article, we are going to learn how to create a String using Batch Script. Batch Script :@echo off set str=Geeks for Geeks echo %str% pauseBy using ' set ' we are getting input of any string.Ex: set str=input stringIn the next line, we are using ' echo %str% ' for printing our input string.Th 1 min read Batch Script - Right String In this article, we are going to learn how to use the concept of Right String using Batch Script. Right String uses the concept of negative indexing. We have to extract the characters using :~ followed by the negative index of the character from which we want to print a substring from the main strin 2 min read Batch Script - Strings A Bash script is a plain text file. This file contains different commands for step-by-step execution. These commands can be written directly into the command line but from a re-usability perceptive it is useful to store all of the inter-related commands for a specific task in a single file. We can u 4 min read Like