Skip to main content

Linux - sed delete line from file

# delete the line 18 from '~/.ssh/known_hosts' file
sed -i '18 d' ~/.ssh/known_hosts

# also
sed -i 18d ~/.ssh/known_hosts

# delete few lines
# delete 6 lines from line 8
sed -i 8,+6d file.txt 


# delete the line where is 'TO DELETE'
sed -i '/TO DELETE/ d' file.txt

Comments

Popular posts from this blog

Start with flask

1. Install python 2. Python comes with pip. Else install pip 3. pip install Flask 4. Create a file flaskFirst.py from flask import Flask app = Flask(__name__) @app.route('/') def index():     return 'Index Page' 3. Go to the path where the flaskFirst.py is present 4. export FLASK_APP=flaskFirst.py 5. flask run