Mac OSX sed - removing a string containing a dot from multiple files
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
Trying to remove a string across multiple files in a directory with sed. The folder contains a large amount of sql files, all with table names that I need to remove. For instance, one of the files looks like this:
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);
I need to remove staging.
from all lines. I've tried the following from the directory where the files are:
sed -i 's/staging.//g' *
sed -i 's/staging.//g' *
sed -i 's|staging.||g' *
But receive the following:
sed: 1: "eav_attribute_set ...": unterminated substitute pattern
sed osx
add a comment |Â
up vote
0
down vote
favorite
Trying to remove a string across multiple files in a directory with sed. The folder contains a large amount of sql files, all with table names that I need to remove. For instance, one of the files looks like this:
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);
I need to remove staging.
from all lines. I've tried the following from the directory where the files are:
sed -i 's/staging.//g' *
sed -i 's/staging.//g' *
sed -i 's|staging.||g' *
But receive the following:
sed: 1: "eav_attribute_set ...": unterminated substitute pattern
sed osx
1
Hmmm... That error message does not correspond in any way to the commands that you've been trying.
â Kusalananda
Aug 28 at 19:22
1
your tag states "osx" but your title states "Linux". Theirsed
implementations are different, which one are you using?
â Kevin Kruse
Aug 28 at 19:22
I'm using macos terminal. I've updated my question/title. Good eyes!
â mindfullsilence
Aug 28 at 19:54
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Trying to remove a string across multiple files in a directory with sed. The folder contains a large amount of sql files, all with table names that I need to remove. For instance, one of the files looks like this:
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);
I need to remove staging.
from all lines. I've tried the following from the directory where the files are:
sed -i 's/staging.//g' *
sed -i 's/staging.//g' *
sed -i 's|staging.||g' *
But receive the following:
sed: 1: "eav_attribute_set ...": unterminated substitute pattern
sed osx
Trying to remove a string across multiple files in a directory with sed. The folder contains a large amount of sql files, all with table names that I need to remove. For instance, one of the files looks like this:
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);
I need to remove staging.
from all lines. I've tried the following from the directory where the files are:
sed -i 's/staging.//g' *
sed -i 's/staging.//g' *
sed -i 's|staging.||g' *
But receive the following:
sed: 1: "eav_attribute_set ...": unterminated substitute pattern
sed osx
sed osx
edited Sep 5 at 2:23
Rui F Ribeiro
36.7k1271117
36.7k1271117
asked Aug 28 at 19:15
mindfullsilence
1032
1032
1
Hmmm... That error message does not correspond in any way to the commands that you've been trying.
â Kusalananda
Aug 28 at 19:22
1
your tag states "osx" but your title states "Linux". Theirsed
implementations are different, which one are you using?
â Kevin Kruse
Aug 28 at 19:22
I'm using macos terminal. I've updated my question/title. Good eyes!
â mindfullsilence
Aug 28 at 19:54
add a comment |Â
1
Hmmm... That error message does not correspond in any way to the commands that you've been trying.
â Kusalananda
Aug 28 at 19:22
1
your tag states "osx" but your title states "Linux". Theirsed
implementations are different, which one are you using?
â Kevin Kruse
Aug 28 at 19:22
I'm using macos terminal. I've updated my question/title. Good eyes!
â mindfullsilence
Aug 28 at 19:54
1
1
Hmmm... That error message does not correspond in any way to the commands that you've been trying.
â Kusalananda
Aug 28 at 19:22
Hmmm... That error message does not correspond in any way to the commands that you've been trying.
â Kusalananda
Aug 28 at 19:22
1
1
your tag states "osx" but your title states "Linux". Their
sed
implementations are different, which one are you using?â Kevin Kruse
Aug 28 at 19:22
your tag states "osx" but your title states "Linux". Their
sed
implementations are different, which one are you using?â Kevin Kruse
Aug 28 at 19:22
I'm using macos terminal. I've updated my question/title. Good eyes!
â mindfullsilence
Aug 28 at 19:54
I'm using macos terminal. I've updated my question/title. Good eyes!
â mindfullsilence
Aug 28 at 19:54
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
2
down vote
accepted
With FreeBSD sed
(as found on macOS), you need:
sed -i '' 's/staging.//g' ./*
add a comment |Â
up vote
0
down vote
This going to remove staging.
in your file.
cat $yourfile | sed 's/staging.//g' > tmp && mv tmp $yourfile
1
That unescaped.
will match any character.
â RudiC
Aug 28 at 20:15
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
With FreeBSD sed
(as found on macOS), you need:
sed -i '' 's/staging.//g' ./*
add a comment |Â
up vote
2
down vote
accepted
With FreeBSD sed
(as found on macOS), you need:
sed -i '' 's/staging.//g' ./*
add a comment |Â
up vote
2
down vote
accepted
up vote
2
down vote
accepted
With FreeBSD sed
(as found on macOS), you need:
sed -i '' 's/staging.//g' ./*
With FreeBSD sed
(as found on macOS), you need:
sed -i '' 's/staging.//g' ./*
edited Aug 29 at 5:55
answered Aug 28 at 20:31
Stéphane Chazelas
285k53526866
285k53526866
add a comment |Â
add a comment |Â
up vote
0
down vote
This going to remove staging.
in your file.
cat $yourfile | sed 's/staging.//g' > tmp && mv tmp $yourfile
1
That unescaped.
will match any character.
â RudiC
Aug 28 at 20:15
add a comment |Â
up vote
0
down vote
This going to remove staging.
in your file.
cat $yourfile | sed 's/staging.//g' > tmp && mv tmp $yourfile
1
That unescaped.
will match any character.
â RudiC
Aug 28 at 20:15
add a comment |Â
up vote
0
down vote
up vote
0
down vote
This going to remove staging.
in your file.
cat $yourfile | sed 's/staging.//g' > tmp && mv tmp $yourfile
This going to remove staging.
in your file.
cat $yourfile | sed 's/staging.//g' > tmp && mv tmp $yourfile
edited Aug 28 at 20:29
answered Aug 28 at 20:00
Javier Salas
1115
1115
1
That unescaped.
will match any character.
â RudiC
Aug 28 at 20:15
add a comment |Â
1
That unescaped.
will match any character.
â RudiC
Aug 28 at 20:15
1
1
That unescaped
.
will match any character.â RudiC
Aug 28 at 20:15
That unescaped
.
will match any character.â RudiC
Aug 28 at 20:15
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f465368%2fmac-osx-sed-removing-a-string-containing-a-dot-from-multiple-files%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
Hmmm... That error message does not correspond in any way to the commands that you've been trying.
â Kusalananda
Aug 28 at 19:22
1
your tag states "osx" but your title states "Linux". Their
sed
implementations are different, which one are you using?â Kevin Kruse
Aug 28 at 19:22
I'm using macos terminal. I've updated my question/title. Good eyes!
â mindfullsilence
Aug 28 at 19:54