john lambert
asked on
how to blend these txt lines in a random way?
how to blend these txt lines in a random way?for example i have this:
john
john1
john123
miami
miami3
miami@1
london123
london
How to blend those lines to look, something like this:
john
miami
john1
london
john123
miami@1
london123
john
john1
john123
miami
miami3
miami@1
london123
london
How to blend those lines to look, something like this:
john
miami
john1
london
john123
miami@1
london123
Nice @Dustin, and way better / shorter than anything hacked together in a DOS BAT approach.
I'm also not aware of any Windows non scripting tools (like SORT.EXE) that have any capability to randomize the output when "sorting".
~bp
I'm also not aware of any Windows non scripting tools (like SORT.EXE) that have any capability to randomize the output when "sorting".
~bp
ASKER
for WINDOWS OS please..and for BIGFILE.TXT
thank you
thank you
You can use Get-Content and the path to the file to get the list from text.
If you want to randomize and write the changes back to your text file, use:
$list = Get-Content "C:\test\list.txt"
$list = $list | Sort-Object {Get-Random}
foreach ($item in $list)
{
Write-Host $item
}
If you want to randomize and write the changes back to your text file, use:
$list = Get-Content "C:\test\list.txt"
$list = $list | Sort-Object {Get-Random}
Set-Content "C:\test\list.txt" $list
Or if you want to write to another file, just change the path after 'Set-Content'
And just to clarify, this is a WINDOWS OS solution using Powershell. You can save the script shown above as a .ps1 file, and then run it from a command line or a batch file by doing:
powershell.exe -ExecutionPolicy Bypass -File EE28977195.ps1
~bp
ASKER
working perfect but can u add please OUTPUT.TXT ??
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
great, thank you...
Example:
Open in new window