Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

sed remove line after match

Use d option at the end of sed command string for deleting line of matches.
sed -i "" "s/matching_pattern/,+1 d" file.txt #+1 defines number of lines
# to delete after matching line
Comment

sed delete line before match

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 #
Comment

sed delete line match

sed '/pattern to match/d' ./infile
Comment

delete strings after match to eol using sed command

$ cat file | awk -F '.com' '{print $1".com"}'
google.com
unix.stackexchange.com
isuckatunix.com
Comment

delete strings after match to eol using sed command

# To explicitly delete everything that comes after ".com", just tweak your existing sed solution to replace ".com(anything)" with ".com":
sed 's/.com.*/.com/' file.txt
Comment

delete strings after match to eol using sed command

# You can use awk's field separator (-F) following way:
$ cat file
google.com/funny
unix.stackexchange.com/questions
isuckatunix.com/ireallydo
Comment

PREVIOUS NEXT
Code Example
Shell :: install bc command linux 
Shell :: install spark 2.4.0 on ubuntu 
Shell :: adobe reader for ubuntu 20.04 
Shell :: how to upgrade pnpm 
Shell :: how to make top bar transparent ubuntu 
Shell :: conemu git bash 
Shell :: list des group linux 
Shell :: git set-url no such remote origin 
Shell :: No module named ipykernel colab conda 
Shell :: cat meaning linux 
Shell :: How to install vscode on centos 8 
Shell :: download composer version 1.6.5 
Shell :: git remove all user data 
Shell :: install watchman on linux 
Shell :: certbot apache subdomain 
Shell :: c linux compiler 
Shell :: how to check gems installed 
Shell :: recursively change file permissions linux 
Shell :: scp linux 
Shell :: ubuntu libqt4 
Shell :: express application generator 
Shell :: Command to find os version of Webserver in nmap 
Shell :: conda install pyav 
Shell :: chnage localhost folder xampp on ubuntu 
Shell :: pushing to existing repo 
Shell :: chsh pam authentication failure 
Shell :: Não foi possível encontrar o pacote youtube-to-mp3 
Shell :: ubuntu rename all files lowercase commands 
Shell :: ssh passphrase stop prompting 
Shell :: list threads in process ubuntu 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =