|
Search for string in a file and extract another string to a variable
Hi, guys. I have one question:
I need to search for a string in a file, and then extract another string from the file and assign it to a variable.
For example:
the contents of the file (group) is below:
...
ftp:x:23:
mail:x:34
...
testing:x:2001
sales:x:2002
development:x:2003
...
I want to search for string "testing", then extract group id (2001) on the same line and assign it to a variable.
Can anybody help me with me question?
Thank you very much for your time in advance
-K.D
|