text processing - How to delete the lines from a file that do not contain dot? - Ask Ubuntu


i have file contains data including urls. there various lines not urls. how can remove them using ubuntu terminal commands?

here sample file reference: sample data

com.blendtuts/s °= com.blengineering.www/:http ±= 

i want have output :

com.blendtuts/s com.blengineering.www/:http 

the unwanted lines not have dot. hence, want remove lines without dots

one way sed

sed '/\./!d' file 
  • /\./ match literal dot (escaped \ because otherwise. matches character)
  • !d delete except matched pattern

if want edit file in place, add -i command after testing. (you can add .bak -i flag sed -i.bak ... create local backup of file.)

sed -i '/\./!d' file 

Comments

Popular posts from this blog

download - Firefox cannot save files (most of the time), how to solve? - Super User

windows - "-2146893807 NTE_NOT_FOUND" when repair certificate store - Super User