You can use Linux sed, awk, or grep commands to delete lines in a text file that contain a specific string
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
## Using sed [sed '/pattern/d' ./infile] cat < Hello everyone welcome to cloudaffaire cloudaffaire loves linux this is debjeet EOF sed -i '/cloud/d' ./file.txt cat file.txt ## Returns ## Hello everyone ## this is debjeet ## Using awk [awk '!/pattern/' file > temp && mv temp file] cat < Hello everyone welcome to cloudaffaire cloudaffaire loves linux this is debjeet EOF awk '!/cloud/' file.txt > temp && mv temp file.txt cat file.txt ## Returns ## Hello everyone ## this is debjeet ## Using grep [grep -v "pattern" file > temp; mv temp file] cat < Hello everyone welcome to cloudaffaire cloudaffaire loves linux this is debjeet EOF grep -v "cloud" file.txt > temp; mv temp file.txt cat file.txt ## Returns ## Hello everyone ## this is debjeet |