FreeKB - do something forward slashes
Bash Shell Scripting - do something forward slashes

Let's say you have a string that contains forward slash, like this.


I find awk to be the easiest tool to cut this string apart. $1 will print the protocol (http in this example).

~]# echo "" | awk -F'/' '{print $1}'


$3 will print the hostname (

~]# echo "" | awk -F'/' '{print $3}'


$4 will print the first part of the context root (foo in this example).

~]# echo "" | awk -F'/' '{print $4}'


Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter 26bf7 in the box below so that we can be sure you are a human.


Web design by yours truely - me, myself, and I   |   |