Extracting name between two delimiters via awk

You can combine two cut commands to extract the server name:

echo <string> | cut -d":" -f1 | cut -d"@" -f2

Explanation:

  • echo <string> | use the string as input
  • cut -d":" -f1 | set field delimiter to : and extract the first field (<user>@<server>)
  • cut -d"@" -f2 set filed delimiter to @ and extract the secon field (<server>)

Yes it is possible - using a regular expression for the delimiter

$ echo '<user>@<server>:<port>:/foo/bar' | awk -F'@|:' '{print $1; print $2; print $3;print $4;}'
<user>
<server>
<port>
/foo/bar

or

$ echo '<user>@<server>:<port>:/foo/bar' | awk -F'[@:]' '{print $1; print $2; print $3;print $4;}'
<user>
<server>
<port>
/foo/bar