Mac OSX sed - 从多个文件中删除包含点的字符串

min*_*nce 1 osx sed

尝试使用 sed 删除目录中多个文件中的字符串。该文件夹包含大量 sql 文件,所有文件都带有我需要删除的表名。例如,其中一个文件如下所示:

INSERT INTO staging.eav_attribute_set (attribute_set_id, entity_type_id, attribute_set_name, sort_order) VALUES (1, 1, 'Default', 2);
INSERT INTO staging.eav_attribute_set (attribute_set_id, entity_type_id, attribute_set_name, sort_order) VALUES (2, 2, 'Default', 2);
INSERT INTO staging.eav_attribute_set (attribute_set_id, entity_type_id, attribute_set_name, sort_order) VALUES (3, 3, 'Default', 1);
INSERT INTO staging.eav_attribute_set (attribute_set_id, entity_type_id, attribute_set_name, sort_order) VALUES (4, 4, 'Default', 1);
Run Code Online (Sandbox Code Playgroud)

我需要staging.从所有行中删除。我从文件所在的目录中尝试了以下内容:

sed -i 's/staging.//g' *
sed -i 's/staging\.//g' *
sed -i 's|staging.||g' *
Run Code Online (Sandbox Code Playgroud)

但收到以下信息:

sed: 1: "eav_attribute_set ...": unterminated substitute pattern
Run Code Online (Sandbox Code Playgroud)

Sté*_*las 5

使用 FreeBSD sed(在 macOS 上可以找到),您需要:

sed -i '' 's/staging\.//g' ./*
Run Code Online (Sandbox Code Playgroud)