sed command to replace a line

Ashish Doneriya

There is a file sample.txt. The contents of this file is

..some content...
  # bind-address = ":7086"
  # bind-address = ":8086"

I want to uncomment the line for port 7086 and replace the port also to 8888 so that final modified file would look like

..some content...
   bind-address = ":8088"
  # bind-address = ":8086"

I want to do it with the sed command. So what will be the exact command?

Utsav

As confirmed in comments, the string always contains # bind-address = ":7086". So to replace it just use sed search and replace option by hardcoding the strings.

sed -i 's/# bind-address = ":7086"/bind-address = ":8088"/' file2

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

How to replace an email in a (PHP) file from the command line without sed?

분류에서Dev

partial line replace command

분류에서Dev

Multi-Line Sed Replace

분류에서Dev

Search and replace sentence with spaces using sed command

분류에서Dev

sed unterminated 's'command modify line of file

분류에서Dev

Command line tool to search and replace text on a PDF

분류에서Dev

Command line tool to search and replace text on a PDF

분류에서Dev

Find and replace a character in xml file using sed command is not working

분류에서Dev

sed: find and replace nth character in a line that starts with a specific string

분류에서Dev

Using sed how to replace a pattern if it occurs on a line following another pattern?

분류에서Dev

sed with replacement part given as input from command line

분류에서Dev

Why does mapping <ESC> start command line Vim in Replace mode?

분류에서Dev

How to run regex find and replace using windows command line

분류에서Dev

Find and Replace Colours in CSS Files from Command Line

분류에서Dev

Execute a command within 'sed'

분류에서Dev

sed next & Next command

분류에서Dev

sed command with option -n and '$='

분류에서Dev

Is there a command-line utility app which can find a specific block of lines in a text file, and replace it?

분류에서Dev

Bash while loop sed replace

분류에서Dev

sed won't replace text

분류에서Dev

Replace with sed appears to do nothing

분류에서Dev

sed 및 sudo with string replace

분류에서Dev

Copy command with command line arguments

분류에서Dev

Execute sed command in a bash script

분류에서Dev

SED command not replacing (working regex)

분류에서Dev

sed command not working with search string

분류에서Dev

Use Variable Date in Sed Command

분류에서Dev

What does this sed command mean?

분류에서Dev

Define variable in command line

Related 관련 기사

뜨겁다태그

보관