Simon336697
asked on
Reading a text fiile
Hi guys, hope you are all good and can assist.
Guys,
We are using an Enterprise build with 10 or so language packs installed.
The user has the option at the start of the build to choose their language.
What we need to do is to trap what language they selected.
This is the Default system UI language.
In the case of that language being English, then the Default system UI language is en-US.
We can grab this by:
dism /online /get-intl > test.txt
The output of test.txt is in the code snippet below.
I have tried different language selections, and the value for Default system UI language appears to be always on Line 9 in the text file.
So my question is.
Is there a way to read the test.txt file, and read a certain line number, in this case, line 9, and trap the value of Default system UI language into a variable?
I cannot do the folowing:
dism /Online /Get-Intl | find "Default system UI language"
This would work if the language chosen was English, but if the language chosen was Chinese for example, then
dism /Online /Get-Intl ^| find "Default system UI language"
would fail to find "Default system UI language" since the text is in Chinese.
Which is why I want to read line number 9, and find the value after the colon.
line9 (english) Default system UI language : en-US
line9 (german) <in german.....>: de-DE
So, something like,
1) read text file
2) read line number 9
if de-DE, then we know its German
if en-US, then we know its English
if es-ES, then we know its Spain
if fr-FR, then we know its France
if it-IT, then we know its Italy
if ja-JP, then we know its Japanese
if nb-NO, then we know its Norway
if pl-PL, then we know its Poland
if pt-BR, then we know its Brasil
if ru-RU, then we know its Russian
if zh-CN, then we know its Simplified Chinese
if zh-HK, then we know its Traditional Chinese
Any help greatly appreciated.
Guys,
We are using an Enterprise build with 10 or so language packs installed.
The user has the option at the start of the build to choose their language.
What we need to do is to trap what language they selected.
This is the Default system UI language.
In the case of that language being English, then the Default system UI language is en-US.
We can grab this by:
dism /online /get-intl > test.txt
The output of test.txt is in the code snippet below.
I have tried different language selections, and the value for Default system UI language appears to be always on Line 9 in the text file.
So my question is.
Is there a way to read the test.txt file, and read a certain line number, in this case, line 9, and trap the value of Default system UI language into a variable?
I cannot do the folowing:
dism /Online /Get-Intl | find "Default system UI language"
This would work if the language chosen was English, but if the language chosen was Chinese for example, then
dism /Online /Get-Intl ^| find "Default system UI language"
would fail to find "Default system UI language" since the text is in Chinese.
Which is why I want to read line number 9, and find the value after the colon.
line9 (english) Default system UI language : en-US
line9 (german) <in german.....>: de-DE
So, something like,
1) read text file
2) read line number 9
if de-DE, then we know its German
if en-US, then we know its English
if es-ES, then we know its Spain
if fr-FR, then we know its France
if it-IT, then we know its Italy
if ja-JP, then we know its Japanese
if nb-NO, then we know its Norway
if pl-PL, then we know its Poland
if pt-BR, then we know its Brasil
if ru-RU, then we know its Russian
if zh-CN, then we know its Simplified Chinese
if zh-HK, then we know its Traditional Chinese
Any help greatly appreciated.
Deployment Image Servicing and Management tool
Version: 6.1.7600.16385
Image Version: 6.1.7600.16385
Reporting online international settings.
Default system UI language : en-US
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Good ol' grep.
Next question would be how to isolate the sixth element after splitting the line using the space as delimiter.
Next question would be how to isolate the sixth element after splitting the line using the space as delimiter.
Ok, download sed also: http://gnuwin32.sourceforge.net/packages/sed.htm
grep "Default system UI language : \(.*\)" deleteme.txt | sed "s/Default system UI language : \(.*\)$/\1/"
yields: en-US
And I used deleteme.txt instead of temp.txt
grep "Default system UI language : \(.*\)" deleteme.txt | sed "s/Default system UI language : \(.*\)$/\1/"
yields: en-US
And I used deleteme.txt instead of temp.txt
You should also get GAwk for Windows to isolate the result. So you would go like this:
C:\> grep "Default system UI language :" deleteme.txt | gawk -F": " "{ print $2 }"
en-US
@rfportilla beat me to post ;-).
Use sed or gawk, but not both.
Use sed or gawk, but not both.
Sorry, @lexlythius. You snooze, you lose. ;-)
ASKER
Guys thanks so much for your help.
The following works, but I get 1 space before "en-US". Is there any way to get rid of this?
for /f "tokens=1* delims=:" %a in ('dism /online /get-intl ^| find /N "en-US" ^| find "[9]"') do @echo %b
en-US
The following works, but I get 1 space before "en-US". Is there any way to get rid of this?
for /f "tokens=1* delims=:" %a in ('dism /online /get-intl ^| find /N "en-US" ^| find "[9]"') do @echo %b
en-US
When you do it this way, you have to specify what you are looking for. What if the language is not en-US? The methods we were giving above don't require you to know the language. If you need to use the command to produce this, you can use
dism /online /get-intl | grep "Default system UI language : \(.*\)" | sed "s/Default system UI language : \(.*\)$/\1/"
dism /online /get-intl | grep "Default system UI language : \(.*\)" | sed "s/Default system UI language : \(.*\)$/\1/"
Ok, this is the last response you're getting from me:
for /f "tokens=5* delims= " %a in ('dism /online /get-intl ^| find /N "Default" ^| find "[9]"') do @echo %b
for /f "tokens=5* delims= " %a in ('dism /online /get-intl ^| find /N "Default" ^| find "[9]"') do @echo %b
Actually should be:
for /f "tokens=5* delims= " %a in ('type deleteme.txt ^| find /N "Default system UI language : " ^| find "[9]"') do @echo %b
Just to be on the safe side.
for /f "tokens=5* delims= " %a in ('type deleteme.txt ^| find /N "Default system UI language : " ^| find "[9]"') do @echo %b
Just to be on the safe side.
Ok, really, the last post. Drop the find [9], just in case the output is changed and it no longer appears on the 9th line, this will work anyway:
for /f "tokens=5* delims= " %a in ('dism /online /get-intl ^| find /N "Default system UI language : "') do @echo %b
for /f "tokens=5* delims= " %a in ('dism /online /get-intl ^| find /N "Default system UI language : "') do @echo %b
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Has this been resolved? I think we have several viable answers here. Please inform. Thx.
http://msdn.microsoft.com/en-us/library/9bbdkx3k(v=vs.85).aspx
http://en.wikipedia.org/wiki/Windows_Script_Host