get rid of multiple words using sed
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
I'm trying to get rid of the following input using sed:
branch
branch
not
"git
"git
That is an empty line, the term branch, not and "git. However the following line does not work:
git status 2>&1 | awk 'print $2' | sed 's/^$//g' | sed 's/^branch||^not||^changes||^"git//g'
How can I write this line correctly to get rid of all of this at once?
command-line text-processing
add a comment |Â
up vote
1
down vote
favorite
I'm trying to get rid of the following input using sed:
branch
branch
not
"git
"git
That is an empty line, the term branch, not and "git. However the following line does not work:
git status 2>&1 | awk 'print $2' | sed 's/^$//g' | sed 's/^branch||^not||^changes||^"git//g'
How can I write this line correctly to get rid of all of this at once?
command-line text-processing
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I'm trying to get rid of the following input using sed:
branch
branch
not
"git
"git
That is an empty line, the term branch, not and "git. However the following line does not work:
git status 2>&1 | awk 'print $2' | sed 's/^$//g' | sed 's/^branch||^not||^changes||^"git//g'
How can I write this line correctly to get rid of all of this at once?
command-line text-processing
I'm trying to get rid of the following input using sed:
branch
branch
not
"git
"git
That is an empty line, the term branch, not and "git. However the following line does not work:
git status 2>&1 | awk 'print $2' | sed 's/^$//g' | sed 's/^branch||^not||^changes||^"git//g'
How can I write this line correctly to get rid of all of this at once?
command-line text-processing
edited Aug 7 at 1:03
muru
128k19268458
128k19268458
asked Aug 6 at 21:07
user99201
1083
1083
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
The correct way of doing what you are trying to achieve:
git status --porcelain | sed s/^...//
From git help status
:
--porcelain[=]
Give the output in an easy-to-parse format for scripts. This is similar to the short output.
And here is what you want to use with your commands:
Using sed
:
... | sed -r '/(^"git|^branch|^not|^$)/d'
Using grep
:
... | grep -Ev '^branch|^not|^"git|^$'
Which returns file names from your git
and awk
command.
That is REALLY helpful. Thank you!
â user99201
Aug 6 at 21:39
@user99201 You're welcome ;)
â Ravexina
Aug 6 at 21:41
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
The correct way of doing what you are trying to achieve:
git status --porcelain | sed s/^...//
From git help status
:
--porcelain[=]
Give the output in an easy-to-parse format for scripts. This is similar to the short output.
And here is what you want to use with your commands:
Using sed
:
... | sed -r '/(^"git|^branch|^not|^$)/d'
Using grep
:
... | grep -Ev '^branch|^not|^"git|^$'
Which returns file names from your git
and awk
command.
That is REALLY helpful. Thank you!
â user99201
Aug 6 at 21:39
@user99201 You're welcome ;)
â Ravexina
Aug 6 at 21:41
add a comment |Â
up vote
3
down vote
accepted
The correct way of doing what you are trying to achieve:
git status --porcelain | sed s/^...//
From git help status
:
--porcelain[=]
Give the output in an easy-to-parse format for scripts. This is similar to the short output.
And here is what you want to use with your commands:
Using sed
:
... | sed -r '/(^"git|^branch|^not|^$)/d'
Using grep
:
... | grep -Ev '^branch|^not|^"git|^$'
Which returns file names from your git
and awk
command.
That is REALLY helpful. Thank you!
â user99201
Aug 6 at 21:39
@user99201 You're welcome ;)
â Ravexina
Aug 6 at 21:41
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
The correct way of doing what you are trying to achieve:
git status --porcelain | sed s/^...//
From git help status
:
--porcelain[=]
Give the output in an easy-to-parse format for scripts. This is similar to the short output.
And here is what you want to use with your commands:
Using sed
:
... | sed -r '/(^"git|^branch|^not|^$)/d'
Using grep
:
... | grep -Ev '^branch|^not|^"git|^$'
Which returns file names from your git
and awk
command.
The correct way of doing what you are trying to achieve:
git status --porcelain | sed s/^...//
From git help status
:
--porcelain[=]
Give the output in an easy-to-parse format for scripts. This is similar to the short output.
And here is what you want to use with your commands:
Using sed
:
... | sed -r '/(^"git|^branch|^not|^$)/d'
Using grep
:
... | grep -Ev '^branch|^not|^"git|^$'
Which returns file names from your git
and awk
command.
edited Aug 6 at 21:32
answered Aug 6 at 21:18
Ravexina
24.5k136185
24.5k136185
That is REALLY helpful. Thank you!
â user99201
Aug 6 at 21:39
@user99201 You're welcome ;)
â Ravexina
Aug 6 at 21:41
add a comment |Â
That is REALLY helpful. Thank you!
â user99201
Aug 6 at 21:39
@user99201 You're welcome ;)
â Ravexina
Aug 6 at 21:41
That is REALLY helpful. Thank you!
â user99201
Aug 6 at 21:39
That is REALLY helpful. Thank you!
â user99201
Aug 6 at 21:39
@user99201 You're welcome ;)
â Ravexina
Aug 6 at 21:41
@user99201 You're welcome ;)
â Ravexina
Aug 6 at 21:41
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%2faskubuntu.com%2fquestions%2f1063006%2fget-rid-of-multiple-words-using-sed%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