Hello all,
i am new one to this forum.
:[bash]
i have file with these contents..
internal://project/squid-internal-static/icons/anthony-xpm.gif
http://widget.blogrush.com/img/br.png
http://www.wingware.com/css/print
http://publib.boulder.ibm.com/infocenter/systems/advanced/filterwarning.css

ftp://shan.org/pdg/asd/bin.jpg
ftp://pop.ces.co.uk/qwer/gft.js
.....................................................
....................................................
....................................................
....................................................
i try try print only the domains.Like
internal://project
http://widget.blogrush.com
Wingware Python IDE - The Intelligent Development Environment for Python Programmers
ftp://pop.ces.co.uk
My problem is every line start with differently.Like
http://, ftp:// ...
and end with .co.uk , .co.in , .com
i try awk command.
awk 'BEGIN{OFS=FS="/"} {print $1 $2}' filename
but o/p is
internal:
http:
ftp:
http:
Pls help me.
Here is one possible solution:
sed -n -e 's|\(^.*://[a-z.-]*\)/.*|\1|p' file
Probably, all your problem are in forgetting to put back delimiter '/'
It works for me:
> cat > try.t
internal://project/squid-internal-static/icons/anthony-xpm.gif
http://widget.blogrush.com/img/br.png
http://www.wingware.com/css/print
http://publib.boulder.ibm.com/infoce...terwarning.css
http://www.blogger.com/img/navbar/1/corner.gif
ftp://shan.org/pdg/asd/bin.jpg
ftp://pop.ces.co.uk/qwer/gft.js
^C
>nawk -F/ '{ print $1"/"$2"/"$3; }' try.t
internal://project
http://widget.blogrush.com
http://www.wingware.com
http://publib.boulder.ibm.com
http://www.blogger.com
ftp://shan.org
ftp://pop.ces.co.uk
fpmurphy: your solution does not works for me some why.
>sed -n -e 's|\(^.*://[a-z.-]*\)/.*|\1|p' try.t
>
[/quote]
The tag does not works. Whithout tag it works:
c> sed -n 's|^.*://[a-z.-]*/|lll_|p' try.t
lll_squid-internal-static/icons/anthony-xpm.gif
lll_img/br.png
lll_css/print
lll_infoce...terwarning.css
lll_img/navbar/1/corner.gif
lll_pdg/asd/bin.jpg
lll_qwer/gft.js
>
c> alias sed
bash: alias: `sed' not found
> which sed
/bin/sed
Any idea why?
I think this one is ok for you.
awk 'BEGIN{FS="/"}{print$1"/"$2"/"$3}' filename