PowerShell Sort file 2 by column in file 1 -
i have 2 txt files.
file 1 file2 sql00003 test1.txt test1.txt sql00002 test3.txt test3.txt sql00001 test5.txt test5.txt file 1 needs sorted column 1 file2 needs in same sequence file 1
(sorted col2 of file1) test5.txt test3.txt test1.txt is possible powershell?
the problem statement odd, piece of key info missing either on file contents or sorting rules.
as far understand question, why bother sorting sec file @ all? per data, contains subset of first file's content. extract first file's sec column after sort so,
# declare headers file looks csv $f = import-csv file1.txt -delimiter " " -header sql, file # csv structured, can sorted column $sorted = $f | sort -property sql # extract file column , add together content new file $sorted | select -expandproperty file | set-content file1b.txt # output cat file1b.txt test5.txt test3.txt test1.txt if not after, please add together more content question.
powershell
No comments:
Post a Comment