Can someone help me awk this line out of a file -
buried within this meta file i have, is another file name. I need to pull the file name out:
<?xml version="1.0"?>ne]# cat example.meta <Meta> <FileModTime>1244613601</FileModTime> <FileSize>3862203</FileSize> <FileSource>file:///home/log/boyd/archive/boyd.log_2009-06-10T02:00:01.log</FileSource> </Meta> I have a ton of these meta files and if they exist i need to pull out the log file: "/home/log/boyd/archive/boyd.log_2009-06-10T02:00:01.log" and then delete that log file from another directory - I think i can script the rest, i just can't figure out how to just pull the log file name out of the meta file I'm just not very strong with awk, I assume there's a way to do it - Thx in advance for any tips - |
I just came up with this command, but it seems to work, not sure its the most efficient but it works
cat 000-2009-06-10T02:02:11-0-r_boyd.meta |grep archive |awk -F"/" '{ print $8}'|awk -F"<" '{ print $1}' Let me know if you see anything wrong with passing multiple awk commands |
I put your test into a file named "fil":
Code:
[mherring@mystical play]$ awk -F"/" '{print $8}' fil This works: Code:
[mherring@mystical play]$ sed -n '/archive/{s/<[^>]*>//g;s/file:\/\///p}' fil |
If you are happy to change the delimeters this can be made a little shorter:
sed -n '/archive/{s|.*file://\(.*\)<.*|\1|p}' |
All times are GMT -5. The time now is 05:51 PM. |