BASH (grep / sed / awk): find string within a (line) range
I have this kind of akward string search.
Lets say I have this text file called "test.cnf": Code:
[client] What it means is, I have to search only beneath [client] but not beneath [server]. There are 2 tabs between "port mysql" and "= 1234" Both [client] and [server] parts are in one text file. THANKS! |
Code:
sed -n '/\[server\]/,/^$/{ /port mysql/p }' test.cnf The mysql config files use a blank line between sections, which allows you to easily end select the end of the range. |
Thanks [edit: also for the VERY fast response!!!] it worked!!!!!!!!!!!!!!!!!!!!
|
All times are GMT -5. The time now is 07:25 AM. |