I have a text file on a Linux machine which contains the strings:
appset.org 87.76.29.21 ns1.appset.org ns2.appset.org
bbchannel.eu 87.77.29.25 ns1.appset.org ns2.appset.org
cyberset.it 87.76.29.22 ns1.appset.org ns2.appset.org
cybersetsystems.com 87.76.29.21 ns1.appset.org ns2.appset.org
romelidays.com 87.98.29.21 ns1.appset.org ns2.appset.org
novaprospect.eu 87.76.29.21 ns1.appset.org ns2.appset.org
All I want is to remove the part starting from the IP address and get output with only website name eg appset.org
,bbchannel.eu
.
The code I have tried is:
#!/bin/bash
while read p; do
echo "$p" | cut -c 1-13
done <experiment
But it doesn't seem to be right. I have also tried using the sed
command but still my logic doesn't work. I am really new to bash. Any help would be really appreciated.
${p/ */}
? – Kilian Foth Nov 02 '20 at 11:07