Hi all,
I want to extract "this_data" from the string below using awk
<Bundle_Name>this_data</Bundle_Name>
Any help would be appreciated
Hi all,
I want to extract "this_data" from the string below using awk
<Bundle_Name>this_data</Bundle_Name>
Any help would be appreciated
Something like this ?
$ echo "<Bundle_Name>this_data</Bundle_Name>" | awk -F "[>,<]" '{print $3}'
this_data
** here I am using two FS
> echo "<Bundle_Name>this_data</Bundle_Name>"
<Bundle_Name>this_data</Bundle_Name>
> echo "<Bundle_Name>this_data</Bundle_Name>" | awk -F">" '{print $2}' | awk -F"<" '{print $1}'
this_data
If you have a string, i.e., a variable, you don't need awk; the shell can do it internally:
string='<Bundle_Name>this_data</Bundle_Name>'
temp=${string#<*>}
printf "%s\n" "${temp%<*>}"
Thanks guys for all you help, much appreciated
use strict;
my $str='<Bundle_Name>this_data</Bundle_Name>';
$str=~/^<[^>]*>([^<]*)<[^>]*>$/;
print $1;
echo '<Bundle_Name>this_data</Bundle_Name>' | sed 's/\(<.*>\)\(.*\)\(<.*>\)/\2/'