Simple but can't figure it out: print or store value from egrep statement
Hi!
Quick q: I want to filter out only the location from a file path. I.e. getting only the string /root/ from the string /root/file.db . I do this using regexp, no problem. So if I have the file path text string in a file I'm getting what I want using: Code:
egrep '^(.*[\\\/])' /path/to/file /root/file.db with /root/ in red color. But how the h**l do I extract that into a variable? If I use awk with the same regexp it prints the whole line. And Code:
var=$(egrep '^(.*[\\\/])' /path/to/file) Regards, Pelle |
You can use dirname to do this:
Code:
dirname /root/test |
That was a much easier way! :D
Thanks a lot! /P |
All times are GMT -5. The time now is 04:50 PM. |