Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

trimspace in bact file

@echo off 
set str = This string    has    a  lot  of spaces 
echo %str% 

set str=%str:=% 
echo %str%
Comment

trim all space in bact file

@echo off
setlocal EnableDelayedExpansion
set S=  This  is  a  test
echo %S%.
for /f "tokens=* delims= " %%a in ('echo %S%') do (set b=%%a & set b=!b: =_! & echo !b!)
endlocal & goto :EOF
Comment

trim all space in bact file

:Trim
SetLocal EnableDelayedExpansion
set Params=%*
for /f "tokens=1*" %%a in ("!Params!") do EndLocal & set %1=%%b
exit /b
Comment

trim all space in bact file

  @ECHO OFF
  SETLOCAL ENABLEDELAYEDEXPANSION

  SET /p NAME=- NAME ? 
  ECHO "%NAME%"
  CALL :TRIM NAME
  ECHO "%NAME%"
  GOTO :EOF

  :TRIM
  SetLocal EnableDelayedExpansion
  Call :TRIMSUB %%%1%%
  EndLocal & set %1=%tempvar%
  GOTO :EOF

  :TRIMSUB
  set tempvar=%*
  GOTO :EOF
Comment

PREVIOUS NEXT
Code Example
Shell :: how to make QtWebengine have smooth scrolling 
Shell :: openssh setup firewall on windows 
Shell :: xargs parameter 
Shell :: windows commandline zip 
Shell :: -----Mg: *scratch* (fundamental)----All-------------------------------------------------------------------------------- 
Shell :: remove git from local repository 
Shell :: docker compose limit logs 
Shell :: how to run powershell without admin rights 
Shell :: The current application is not compatible with NativeScript CLI 8.0.2 
Shell :: helm rhel 
Shell :: ubuntu install brew 
Shell :: git commit message conventions 
Shell :: ls order by filename length 
Shell :: hide date from terminal ubuntu 
Shell :: how to kill running port in ubuntu 
Shell :: how to commit to main branch in git 
Shell :: how to check date is older than x days in shell script 
Shell :: install jenkins on ubuntu 20.04 
Shell :: copy files from s3 to ec2 vice versa 
Shell :: docker compose up 
Shell :: How to install LAMP in CentOs? 
Shell :: install mongoes 
Shell :: grep wildcard 
Shell :: laravel start kit authentication 
Shell :: ubuntu vs lubuntu 
Shell :: how to silence operation not permitted 
Shell :: get docker image from docker hub 
Shell :: linux alternatives to tree 
Shell :: how to delay the start of a program linux 
Shell :: plt .show matplotlib remote vscode 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =