I have a text file that I would like to be sorted (or just displayed) in alphabetical order
Currently I am using 'for /f "tokens=* delims=" %%a in (myfile.txt) do echo %%a'
I simply want the output alphabetical, any solution is fine
Sorting list in alphabetical order?
Moderator: DosItHelp
Re: Sorting list in alphabetical order?
Displayed:
Redirected into another file:
Code: Select all
sort <file.txt
Redirected into another file:
Code: Select all
sort <file.txt >outfile.txt
-
- Posts: 43
- Joined: 20 Mar 2012 20:53
Re: Sorting list in alphabetical order?
Code: Select all
for /f "tokens=* delims=" %%a in ('sort <myfile.txt') do echo %%a
Output:
Code: Select all
< was unexpected at this time.
C:\Users\User\Desktop>
How could I accomplish this in this format?? The file is not organized in a way that would generate suitable output from 'sort <myfile.txt' so I was hoping I could embed this in a for loop as opposed to restructuring the whole file
Re: Sorting list in alphabetical order?
You must escape the < redirection sign:Note that tokens=* is not required in this case:
Code: Select all
for /f "tokens=* delims=" %%a in ('sort ^<myfile.txt') do echo %%a
Code: Select all
for /f "delims=" %%a in ('sort ^<myfile.txt') do echo %%a
-
- Posts: 43
- Joined: 20 Mar 2012 20:53
Re: Sorting list in alphabetical order?
Thank you very much Aacini and foxidrive Problem solved