1.

Solve : Doubt in cmd comands.?

Answer»

Hello every one

I have facing a problem while echo a list on command promt , and need the help .

I have a list: LIST=abc:::123:::xyz
Now i want to print this list in a file as follows:
abc
123
xyz

Now i dont know how to do it , PLZ help me to slove this.

Thanks in advance.Code: [Select]REM SET LIST
set LIST=abc:::123:::xyz
REM CHANGE ::: TO "SPACE"
set LIST=%LIST::::= %

REM GET ALL TOKENS ON LIST
for %%a in (%LIST%) do echo %%a

pauseC:\>TYPE finalstr.bat
Code: [Select]@echo off
set str=abc:::123:::xyz
echo."%str%"
set str=%str::= %
echo %str%

for /f "tokens=1,2,3,4 delims= " %%a in ("%str%") do ( set x=%%a & set y=%%b & s
et z=%%c)

echo.x: %x%
echo.y: %y%
echo.z: %z%



echo %x% > savestr.txt
echo %y% >> savestr.txt
echo %z% >> savestr.txt

echo. The file with each string on separate line

Type savestr.txt
Output of finalstr.bat

C:\>finalstr.bat
Quote

"abc:::123:::xyz"
abc 123 xyz
x: abc
y: 123
z: xyz
The file with each string on separate line
abc
123
xyz
C:\>
thanks, it helps me if you have gawk for WINDOWS(see my sig )
Code: [Select]C:\TEST>set str=abc:::123:::xyz

C:\test>echo %str%|gawk -F":::" "$1=$1" OFS="\n"
abc
123
xyz

redirect to new file as needed.


Discussion

No Comment Found