Using Grep on txt file to find 7 letter words that start with the same letter
grep -i "^(.).*1$" sowpods.txt > output.txt
I'm using a scrabble words list I downloaded named "sowpods.txt" and I am trying to use grep to find all of the 7 letter words in the file that start and end with the same letter .The line I have now is giving me a backreference error so I tried using online guides but they were insanely confusing. Could someone help me do this? Thanks!
I'm also on a mac and am using the default terminal.
command-line bash grep
add a comment |
grep -i "^(.).*1$" sowpods.txt > output.txt
I'm using a scrabble words list I downloaded named "sowpods.txt" and I am trying to use grep to find all of the 7 letter words in the file that start and end with the same letter .The line I have now is giving me a backreference error so I tried using online guides but they were insanely confusing. Could someone help me do this? Thanks!
I'm also on a mac and am using the default terminal.
command-line bash grep
2
Please don't make more work for other people by vandalizing your posts. By posting on the Stack Exchange (SE) network, you've granted a non-revocable right, under the CC BY-SA 3.0 license for SE to distribute that content. By SE policy, any vandalism will be reverted. If you want to know more about deleting a post, please take a look at: How does deleting work?
– iBot
Feb 12 at 21:22
add a comment |
grep -i "^(.).*1$" sowpods.txt > output.txt
I'm using a scrabble words list I downloaded named "sowpods.txt" and I am trying to use grep to find all of the 7 letter words in the file that start and end with the same letter .The line I have now is giving me a backreference error so I tried using online guides but they were insanely confusing. Could someone help me do this? Thanks!
I'm also on a mac and am using the default terminal.
command-line bash grep
grep -i "^(.).*1$" sowpods.txt > output.txt
I'm using a scrabble words list I downloaded named "sowpods.txt" and I am trying to use grep to find all of the 7 letter words in the file that start and end with the same letter .The line I have now is giving me a backreference error so I tried using online guides but they were insanely confusing. Could someone help me do this? Thanks!
I'm also on a mac and am using the default terminal.
command-line bash grep
command-line bash grep
edited Feb 12 at 21:49
Kamil Maciorowski
28.6k156187
28.6k156187
asked Sep 10 '18 at 13:53
Kappa123Kappa123
62
62
2
Please don't make more work for other people by vandalizing your posts. By posting on the Stack Exchange (SE) network, you've granted a non-revocable right, under the CC BY-SA 3.0 license for SE to distribute that content. By SE policy, any vandalism will be reverted. If you want to know more about deleting a post, please take a look at: How does deleting work?
– iBot
Feb 12 at 21:22
add a comment |
2
Please don't make more work for other people by vandalizing your posts. By posting on the Stack Exchange (SE) network, you've granted a non-revocable right, under the CC BY-SA 3.0 license for SE to distribute that content. By SE policy, any vandalism will be reverted. If you want to know more about deleting a post, please take a look at: How does deleting work?
– iBot
Feb 12 at 21:22
2
2
Please don't make more work for other people by vandalizing your posts. By posting on the Stack Exchange (SE) network, you've granted a non-revocable right, under the CC BY-SA 3.0 license for SE to distribute that content. By SE policy, any vandalism will be reverted. If you want to know more about deleting a post, please take a look at: How does deleting work?
– iBot
Feb 12 at 21:22
Please don't make more work for other people by vandalizing your posts. By posting on the Stack Exchange (SE) network, you've granted a non-revocable right, under the CC BY-SA 3.0 license for SE to distribute that content. By SE policy, any vandalism will be reverted. If you want to know more about deleting a post, please take a look at: How does deleting work?
– iBot
Feb 12 at 21:22
add a comment |
2 Answers
2
active
oldest
votes
This will work as an extended regular expression. You need grep -E
:
grep -E -i "^(.).*1$"
To match 7-letter words you need to replace *
with {5}
:
grep -E -i "^(.).{5}1$"
I'm a fan of the-x
flag:grep -Eix "(.).{5}1"
– Jim L.
Jan 30 at 22:46
add a comment |
If you want to use basic regular expression (without option -E
), you need a backslash before the opening and closing brackets:
grep -i '^(.).{5}1$' file
Note that it's good idea to use single quote in your grep regex in order to avoid shell parameter expansion.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1356890%2fusing-grep-on-txt-file-to-find-7-letter-words-that-start-with-the-same-letter%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
This will work as an extended regular expression. You need grep -E
:
grep -E -i "^(.).*1$"
To match 7-letter words you need to replace *
with {5}
:
grep -E -i "^(.).{5}1$"
I'm a fan of the-x
flag:grep -Eix "(.).{5}1"
– Jim L.
Jan 30 at 22:46
add a comment |
This will work as an extended regular expression. You need grep -E
:
grep -E -i "^(.).*1$"
To match 7-letter words you need to replace *
with {5}
:
grep -E -i "^(.).{5}1$"
I'm a fan of the-x
flag:grep -Eix "(.).{5}1"
– Jim L.
Jan 30 at 22:46
add a comment |
This will work as an extended regular expression. You need grep -E
:
grep -E -i "^(.).*1$"
To match 7-letter words you need to replace *
with {5}
:
grep -E -i "^(.).{5}1$"
This will work as an extended regular expression. You need grep -E
:
grep -E -i "^(.).*1$"
To match 7-letter words you need to replace *
with {5}
:
grep -E -i "^(.).{5}1$"
answered Sep 10 '18 at 14:01
Kamil MaciorowskiKamil Maciorowski
28.6k156187
28.6k156187
I'm a fan of the-x
flag:grep -Eix "(.).{5}1"
– Jim L.
Jan 30 at 22:46
add a comment |
I'm a fan of the-x
flag:grep -Eix "(.).{5}1"
– Jim L.
Jan 30 at 22:46
I'm a fan of the
-x
flag: grep -Eix "(.).{5}1"
– Jim L.
Jan 30 at 22:46
I'm a fan of the
-x
flag: grep -Eix "(.).{5}1"
– Jim L.
Jan 30 at 22:46
add a comment |
If you want to use basic regular expression (without option -E
), you need a backslash before the opening and closing brackets:
grep -i '^(.).{5}1$' file
Note that it's good idea to use single quote in your grep regex in order to avoid shell parameter expansion.
add a comment |
If you want to use basic regular expression (without option -E
), you need a backslash before the opening and closing brackets:
grep -i '^(.).{5}1$' file
Note that it's good idea to use single quote in your grep regex in order to avoid shell parameter expansion.
add a comment |
If you want to use basic regular expression (without option -E
), you need a backslash before the opening and closing brackets:
grep -i '^(.).{5}1$' file
Note that it's good idea to use single quote in your grep regex in order to avoid shell parameter expansion.
If you want to use basic regular expression (without option -E
), you need a backslash before the opening and closing brackets:
grep -i '^(.).{5}1$' file
Note that it's good idea to use single quote in your grep regex in order to avoid shell parameter expansion.
answered Sep 10 '18 at 14:11
olivoliv
31115
31115
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1356890%2fusing-grep-on-txt-file-to-find-7-letter-words-that-start-with-the-same-letter%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
Please don't make more work for other people by vandalizing your posts. By posting on the Stack Exchange (SE) network, you've granted a non-revocable right, under the CC BY-SA 3.0 license for SE to distribute that content. By SE policy, any vandalism will be reverted. If you want to know more about deleting a post, please take a look at: How does deleting work?
– iBot
Feb 12 at 21:22