Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

shell script delete line containing

awk !/searchterm/ ~/.filename > temp && mv temp ~/.filename
That will replace any line containing "searchterm" in the file "filename"

Example:
Input:
	echo "Hello World"
    echo "Goodbye World"
    echo "Hi Developers"
    
Output:
	awk !/Hello/ ~/.greetings > temp && mv temp ~/.greetings
    	echo "Goodbye World"
        echo "Hi Developers"
    
    awk !/world/ ~/.script > temp && mv temp ~/.script
    	echo "Hi Developers"
 
PREVIOUS NEXT
Tagged: #shell #script #delete #line
ADD COMMENT
Topic
Name
8+4 =