I have a string like this
TEST="/dev/sda1 on /media/sda1 type vfat (rw,relatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=cp437,iocharset=iso8859-1,quiet)"
(Result from mount | grep sda1
)
where I want to match the mount point. My regex (adopted from here) is
(?<=on[ \t])(.*)(?=[ \t]type)
But for some reasons it doesn't work for me with several tools (Busybox ash 1.14.2):
echo $TEST | grep -o -e '(?<=on[ \t])(.*)(?=[ \t]type)'
Gives me no result.
echo $TEST | awk 'match($0, /(?<=on )(.*)(?= type)/){print $0}'
Returns an error awk: bad regex '(?<=on[ ])(.*)(?=[ ]type)': Invalid preceding regular expression
expr match "$TEST" '\(?<=on[ \t]\)\(.*\)\(?=[ \t]type\)'
Also returns an empty result.
I feel kinda stupid.
on (.*) type
?echo $TEST | awk '{print $3}'
.echo $TEST | cut -d' ' -f3