在unix中使用sed查找和替换
可能重复:在unix中使用sed查找和替换,unix,sed,Unix,Sed,可能重复: 我需要找到以下字符串/a/b/c,并将其替换为/r/s/t 它是一个字符串,而不是一个文件夹 /sam/pam/nancy-->/tim/cook/iphone 我在目录中,只需要更新包含此行的多个文件。使用sed将文件更改到位。例如: sed -i 's|/a/b/c|/r/s/t|g' *.txt perl -pi -e 's/\/a\/b\/c/\/r\/s\/t/g' file_name
我需要找到以下字符串
/a/b/c
,并将其替换为/r/s/t
它是一个字符串,而不是一个文件夹
/sam/pam/nancy
-->/tim/cook/iphone
我在目录中,只需要更新包含此行的多个文件。使用
sed
将文件更改到位。例如:
sed -i 's|/a/b/c|/r/s/t|g' *.txt
perl -pi -e 's/\/a\/b\/c/\/r\/s\/t/g' file_name