“SED Usuń linię zawierającą” Kod odpowiedzi

SED Usuń linię zawierającą

sed '/pattern to match/d' ./infile
Misty Magpie

Usuń linię zaczynającą się od SED

# Delete all lines starting with '#'
$ sed -i '/^#/d' filepath
Grotesque Gentoo

Usuń linię w SED

# -i here update the file, try with and without -i, 
sed -i -e '/yourpattern/,$d' file # delete everyhing afer the pattern
sed -i -e "/your_pattern/,+2 d" file  # 2 lines after the pattern
sed -i -e "5,5d" file # remove 5th line
sed '10,$d' pes.com # delete everything after 10th line
sed '7,36!d' tmp.com > tmp_coord # specific lines to a file
sed -i -e '29,36d' pes.com delete specific lines 
Hutch Polecat

SED Usuń linię przed dopasowaniem

Use d option at the end of sed command string for deleting line of matches.
tac | sed -i "" "s/matching_pattern/I+1 d" file.txt | tac #
Armandres

Odpowiedzi podobne do “SED Usuń linię zawierającą”

Pytania podobne do “SED Usuń linię zawierającą”

Więcej pokrewnych odpowiedzi na “SED Usuń linię zawierającą” w Shell/Bash

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu