I am having a issue try to remove a file path from results.
Here is a example of results
/opt/coolstack/apache2/htdocs/switchmap/text/mac.map:xxxx-r01 0001.e611.6116 FastEthernet1/4
I would like the results to be
mac.map:xxxx-r01 0001.e611.6116
I am only able to remove one dir without an error.
sed -e 's/opt/coolstack' -e 's/'
Any help would be appericated.
you need to mask the /, since it's a sed control character
sed 's/\/opt\/coolstack\/apache2\/htdocs\/switchmap\/text\///g'
other possibility:
echo "/opt/coolstack/apache2/htdocs/switchmap/text/mac.map:xxxx-r01 0001.e611.6116 FastEthernet1/4" | awk -F \/ '{print $8}'
Edit: sry for doublepost
echo "/opt/coolstack/apache2/htdocs/switchmap/text/mac.map:xxxx-r01 0001.e611.6116 FastEthernet1/4" | awk -F \/ '{print $8}' | awk '{print $1,$2}'
Perfect, thanks for all the help.
didn't see that space, in this case I would do it this way:
awk -F "/| " '{print $8,$9}'
one awk less