0

hello how to remove and clear output ?

test.txt

http://urlcom/longStringxyzABC**|**http://urlcom/longStringxyzABC

i want, | including character deletion after

i want result

http://urlcom/longStringxyzABC

thanks

2
sed 's/|.*//' test.txt

grep -oP '.*?(?=\|)' test.txt

awk -F'|' '{print $1}' test.txt
  • grep -o outputs both (in general all) matches, which is not desired here. – dave_thompson_085 Jun 26 '18 at 1:58
  • @dave_thompson_085 oops good catch, I've amended using PCRE but please feel free to suggest a better alternative – steeldriver Jun 26 '18 at 2:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.