Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hello all
I'm trying to understand Pemente's awk/sed example #2 in using awk/sed to find a line in a text file and sending the content of that line into a variable. A search didn't really help me much...
http://www.student.northpark.edu/pemente/sed/bat_env.htm#sed
"
Example 2: Get John Doe's phone number from FOO.DAT, and put it into the variable %PHONE%@echo off
:: Look for name John Doe, get field #4
awk "/John Doe/ {print \"set phone=\" $4}" FOO.DAT >tmp_.bat
call tmp_.bat
echo John Doe's phone number is /%PHONE%/
::
del tmp_.bat >NUL
set phone=
"
e.g.
Look for "Backup Path=[content]" in a text file, set %backup% to [content] using sed/awk.I don't understand the "get field 4" part of Pemente's example: do we have to know the exact field/line number in the text file beforehand?
I'm using the win32 GNU port for SED, 3.02 (haven't gotten awk yet).
Thanks ahead of time.

>> I'm using the win32 GNU port for SED, 3.02 (haven't gotten awk yet).
If you don't have awk then that's a very good reason why the awk command isn't working!!

No, I mean I haven't tried to write a batch for this yet because I don't understand what that particular line means. :P
I'd like to figure out what the commands are before writing the actual batch. Ah, nevermind...

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |