Search code examples
vimsedgrepcuttr

Delete characters from a big file using vim or grep or other


I have one big file which are contains around 500000 numbers, some of those numbers contains URl,Passwords , as you can see in my below example for my file , i would like to delete those numbers and keep only those numbers that contain Url,Password

101045
101046
101047
101048
101049            <Password>eee33ddrFDE</Password>
      <Url>http://www.example.com/9786140220447.php</Url>
--
      <Password>6tgHDDYUqLH</Password>
      <Url>http://www.example.com/9786140204102.php</Url>
101050
101051
101052
101053
101054

i have try to use cat and grep and vim with

:%s/^.\{6}//

but it will delete all numbers even those numbers which is have Url,Password that i want to keep it.


Solution

  • If you want to get rid of lines without password/URI info, you could try with:

    grep -E "[^0-9]+" filename