regex in shell script

General support questions
Post Reply
Posts: 123
Joined: 2017/02/25 12:41:42

regex in shell script

Post by knzzz » 2018/08/09 03:07:38

Hi All

How to do the below mentioned tasks using shell scripts I have two doubts

1.Let's consider file1.txt i need to edit the content of using vim editor for a specific line which has abc key word

in details

inside the file1.txt xyhz yyzhhh abc tgh

in the above file content i need change the ip which has the line abc key word . How to change it ?

2. how to do the sftp using shell script , sftp is passwordless?

Posts: 528
Joined: 2014/08/07 02:17:29
Location: Tucson, AZ

Re: regex in shell script

Post by desertcat » 2018/08/09 09:57:55

My two favourite program form file editing are mc (Midnight Commander) and Sublime which is "vim" on steroids which is great if you are looking for a specific line number.

User avatar
Posts: 40
Joined: 2017/11/04 00:59:56

Re: regex in shell script

Post by fdisk » 2018/08/09 11:24:10

Something like this:

Code: Select all

sed -r /abc/s/"(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])"/""/g file1.txt

Post Reply