sed inside awk or awk inside awk
Hi Team
I would like to extract last feild from a line with is already parsed to awk. I want to print last feild with sed inside awk or awk inside awk. Code:
$ cat file.log |
awk can do all of the string maniuplations that sed can do, so just do it all in awk.
Code:
awk -F':' '{print "Variable "$1 " has Location " $2 " version of " gensub(".*/", "", 1, $2)}' file.log Yes, gensub() is a GNU extension. If you're using some other version of awk, please specify. |
i have tried this it worked
$ cat file.log | awk -F':' '{print "Variable "$1 " has Location " $2 " version of " substr($2,19)}' Variable LOG_LOC has Location /opt/install/logs/12.2 version of 12.2 but path gets changed due size |
Perfect i got it thanks.
|
Just remember that your substr command requires you to know the data length ahead of time but the gensub requires only the knowledge that the string after the last '/' is required
|
All times are GMT -5. The time now is 07:56 AM. |