Skip to main content
added 8 characters in body
Source Link

Good day all!

I am trying to change the path of directories in a text file using sed cmd.

The servers I have tested the commands are running Rocky Linux 8.5 (Green Obsidian).

Here's the sed command I am using:

sed -i 's|1344P1052_ssl02 /gs:/prod1|sd://prod1-backup|g' example.txt

sed -i 's|1344P1052_ssl09 /gs:/prod1|sd://prod1-backup|g' example.txt

There is no error in the output, but the directory path in the file remains the same.

It should change [example below]

Before:

1344P1052_ssl02 /gs:/prod1/some_notes_heresome_notes_here_1
1344P1052_ssl09 /gs:/prod1/some_notes_heresome_notes_here_2

After:

sd://prod1-backup/some_notes_heresome_notes_here_1
sd://prod1-backup/some_notes_heresome_notes_here_2

I think it does not work because of the space, semi-colons, etc but I googled in this group's answer and read that using |

should work for special chars, backslash and space. Now I am not too sure, so I am just doing it manually with vim line by line.

Appreciate any help really...

Good day all!

I am trying to change the path of directories in a text file using sed cmd.

The servers I have tested the commands are running Rocky Linux 8.5 (Green Obsidian).

Here's the sed command I am using:

sed -i 's|1344P1052_ssl02 /gs:/prod1|sd://prod1-backup|g' example.txt

sed -i 's|1344P1052_ssl09 /gs:/prod1|sd://prod1-backup|g' example.txt

There is no error in the output, but the directory path in the file remains the same.

It should change [example below]

Before:

1344P1052_ssl02 /gs:/prod1/some_notes_here
1344P1052_ssl09 /gs:/prod1/some_notes_here

After:

sd://prod1-backup/some_notes_here
sd://prod1-backup/some_notes_here

I think it does not work because of the space, semi-colons, etc but I googled in this group's answer and read that using |

should work for special chars, backslash and space. Now I am not too sure, so I am just doing it manually with vim line by line.

Appreciate any help really...

Good day all!

I am trying to change the path of directories in a text file using sed cmd.

The servers I have tested the commands are running Rocky Linux 8.5 (Green Obsidian).

Here's the sed command I am using:

sed -i 's|1344P1052_ssl02 /gs:/prod1|sd://prod1-backup|g' example.txt

sed -i 's|1344P1052_ssl09 /gs:/prod1|sd://prod1-backup|g' example.txt

There is no error in the output, but the directory path in the file remains the same.

It should change [example below]

Before:

1344P1052_ssl02 /gs:/prod1/some_notes_here_1
1344P1052_ssl09 /gs:/prod1/some_notes_here_2

After:

sd://prod1-backup/some_notes_here_1
sd://prod1-backup/some_notes_here_2

I think it does not work because of the space, semi-colons, etc but I googled in this group's answer and read that using |

should work for special chars, backslash and space. Now I am not too sure, so I am just doing it manually with vim line by line.

Appreciate any help really...

Remove commands from input data (they are shown earlier anyway)
Source Link
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k

Good day all!

I am trying to change the path of directories in a text file using sed cmd.

The servers I have tested the commands are running Rocky Linux 8.5 (Green Obsidian).

Here's the sed command I am using:

sed -i 's|1344P1052_ssl02 /gs:/prod1|sd://prod1-backup|g' example.txt

sed -i 's|1344P1052_ssl09 /gs:/prod1|sd://prod1-backup|g' example.txt

There is no error in the output, but the directory path in the file remains the same.

It should change [example below]

Before:

1344P1052_ssl02 /gs:/prod1/some_notes_here
1344P1052_ssl09 /gs:/prod1/some_notes_here
 
sed -i 's|1344P1052_ssl02 /gs:/prod1|sd://prod1-backup|g' example.txt
sed -i 's|1344P1052_ssl09 /gs:/prod1|sd://prod1-backup|g' example.txt

After:

sd://prod1-backup/some_notes_here
sd://prod1-backup/some_notes_here

I think it does not work because of the space, semi-colons, etc but I googled in this group's answer and read that using |

should work for special chars, backslash and space. Now I am not too sure, so I am just doing it manually with vim line by line.

Appreciate any help really...

Good day all!

I am trying to change the path of directories in a text file using sed cmd.

The servers I have tested the commands are running Rocky Linux 8.5 (Green Obsidian).

Here's the sed command I am using:

sed -i 's|1344P1052_ssl02 /gs:/prod1|sd://prod1-backup|g' example.txt

sed -i 's|1344P1052_ssl09 /gs:/prod1|sd://prod1-backup|g' example.txt

There is no error in the output, but the directory path in the file remains the same.

It should change [example below]

Before:

1344P1052_ssl02 /gs:/prod1/some_notes_here
1344P1052_ssl09 /gs:/prod1/some_notes_here
 
sed -i 's|1344P1052_ssl02 /gs:/prod1|sd://prod1-backup|g' example.txt
sed -i 's|1344P1052_ssl09 /gs:/prod1|sd://prod1-backup|g' example.txt

After:

sd://prod1-backup/some_notes_here
sd://prod1-backup/some_notes_here

I think it does not work because of the space, semi-colons, etc but I googled in this group's answer and read that using |

should work for special chars, backslash and space. Now I am not too sure, so I am just doing it manually with vim line by line.

Appreciate any help really...

Good day all!

I am trying to change the path of directories in a text file using sed cmd.

The servers I have tested the commands are running Rocky Linux 8.5 (Green Obsidian).

Here's the sed command I am using:

sed -i 's|1344P1052_ssl02 /gs:/prod1|sd://prod1-backup|g' example.txt

sed -i 's|1344P1052_ssl09 /gs:/prod1|sd://prod1-backup|g' example.txt

There is no error in the output, but the directory path in the file remains the same.

It should change [example below]

Before:

1344P1052_ssl02 /gs:/prod1/some_notes_here
1344P1052_ssl09 /gs:/prod1/some_notes_here

After:

sd://prod1-backup/some_notes_here
sd://prod1-backup/some_notes_here

I think it does not work because of the space, semi-colons, etc but I googled in this group's answer and read that using |

should work for special chars, backslash and space. Now I am not too sure, so I am just doing it manually with vim line by line.

Appreciate any help really...

added 39 characters in body
Source Link

Good day all!

I am trying to change the path of directories in a text file using sed cmd.

The servers I have tested the commands are running Rocky Linux 8.5 (Green Obsidian).

Here's the sed command I am using:

sed -i 's|1344P1052_ssl02 /gs:/prod1|sd://prod1-backup|g' example.txt

sed -i 's|1344P1052_ssl09 /gs:/prod1|sd://prod1-backup|g' example.txt

There is no error in the output, but the directory path in the file remains the same.

It should change [example below]

Before:

1344P1052_ssl02 /gs:/prod1/some_notes_here
1344P1052_ssl09 /gs:/prod1/some_notes_here

sed -i 's|1344P1052_ssl02 /gs:/prod1|sd://prod1-backup|g' example.txt
sed -i 's|1344P1052_ssl09 /gs:/prod1|sd://prod1-backup|g' example.txt

After:

sd://prod1-backup/some_notes_here
sd://prod1-backup/some_notes_here

I think it does not work because of the space, semi-colons, etc but I googled in this group's answer and read that using |

should work for special chars, backslash and space. Now I am not too sure, so I am just doing it manually with vim line by line.

Appreciate any help really...

Good day all!

I am trying to change the path of directories in a text file using sed cmd.

The servers I have tested the commands are running Rocky Linux 8.5 (Green Obsidian).

Here's the sed command I am using:

sed -i 's|1344P1052_ssl02 /gs:/prod1|sd://prod1-backup|g' example.txt

sed -i 's|1344P1052_ssl09 /gs:/prod1|sd://prod1-backup|g' example.txt

There is no error in the output, but the directory path in the file remains the same.

It should change [example below]

Before:

1344P1052_ssl02 /gs:/prod1/some_notes_here
1344P1052_ssl09 /gs:/prod1/some_notes_here

sed -i 's|1344P1052_ssl02 /gs:/prod1|sd://prod1-backup|g' example.txt
sed -i 's|1344P1052_ssl09 /gs:/prod1|sd://prod1-backup|g' example.txt

After:

sd://prod1-backup/some_notes_here

I think it does not work because of the space, semi-colons, etc but I googled in this group's answer and read that using |

should work for special chars, backslash and space. Now I am not too sure, so I am just doing it manually with vim line by line.

Appreciate any help really...

Good day all!

I am trying to change the path of directories in a text file using sed cmd.

The servers I have tested the commands are running Rocky Linux 8.5 (Green Obsidian).

Here's the sed command I am using:

sed -i 's|1344P1052_ssl02 /gs:/prod1|sd://prod1-backup|g' example.txt

sed -i 's|1344P1052_ssl09 /gs:/prod1|sd://prod1-backup|g' example.txt

There is no error in the output, but the directory path in the file remains the same.

It should change [example below]

Before:

1344P1052_ssl02 /gs:/prod1/some_notes_here
1344P1052_ssl09 /gs:/prod1/some_notes_here

sed -i 's|1344P1052_ssl02 /gs:/prod1|sd://prod1-backup|g' example.txt
sed -i 's|1344P1052_ssl09 /gs:/prod1|sd://prod1-backup|g' example.txt

After:

sd://prod1-backup/some_notes_here
sd://prod1-backup/some_notes_here

I think it does not work because of the space, semi-colons, etc but I googled in this group's answer and read that using |

should work for special chars, backslash and space. Now I am not too sure, so I am just doing it manually with vim line by line.

Appreciate any help really...

deleted 75 characters in body
Source Link
Loading
Source Link
Loading