0

I want to cut url to terminal output but it returns several times same domain I can cut https://blabla.domain.com with this

grep -Eo '(http|https)://[^/"]+'

But I want delete repeat of same domain and http:// tag.

my output is:

https://blabla.domain.com
https://blabla.domain.com
https://blabla.domain.com
https://blabla.domain.com

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
  • You can pipe your input to `sort` and `uniq` to filter identical rows. Something like `grep -Eo '(http|https)://[^/"]+' | sort | uniq` – AvyChanna May 25 '21 at 08:00
  • Not worked, nothing happened and itsread any text from file kaandikec@kaandikec-server:~$ grep -Eo text.txt'(http|https)://[^/"]+' | sort | uniq http://test.com http://test.com ^C kaandikec@kaandikec-server:~$ – KAAN DİKEÇ May 25 '21 at 08:28
  • @KAANDİKEÇ please click [edit] and add a few sample lines from `text.txt` for us to test.. as well as complete expected output for that sample – Sundeep May 25 '21 at 09:04
  • Oh sorry, I forgot to mention that you need to change this command to provide input. Something like `grep -Eo '(http|https)://[^/"]+' test.txt | sort | uniq` or `cat test.txt | grep -Eo '(http|https)://[^/"]+' | sort | uniq`. Otherwise, input will be read from stdin and result will be printed when you send EOF (usually by Ctrl+D). – AvyChanna May 25 '21 at 14:29

0 Answers0