-
-
Notifications
You must be signed in to change notification settings - Fork 88
Manchester | 25-SDC-Nov | Rahwa Haile | Sprint 1 | Individual shell tools #198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 12 commits
139ddaf
3060f99
d9dc541
9b6093b
2a03983
d0ec01b
cd830fc
c285238
c8fcdae
a332f8c
e263848
a9cb0f8
8021272
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,3 +6,4 @@ set -euo pipefail | |
| # If a line starts with a number and a space, make the line instead end with a space and the number. | ||
| # So line 6 which currently reads "37 Alisha" should instead read "Alisha 37". | ||
| # The output should contain 11 lines. | ||
| sed -E "s/^[[:space:]]*([0-9]+)[[:space:]]+(.*)$/\2 \1/" input.txt | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you need to specify [[:space:]] in this manner to match on spaces?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added [[:space:]] in the sed command for safety because it matches any whitespace character (spaces or tabs). For my input, which only contains spaces, it wasn’t strictly necessary, but using [[:space:]] makes the command more robust and portable for files that might contain tabs or mixed whitespace. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for clarifying, it's good you know these different methods that can help depending on the input |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you use the "quotes" here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I add quotes for safety, because if the folder name ever contains spaces or special characters, the shell will interpret it incorrectly. Without quotes, a name with spaces would be treated as separate arguments and cause errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good answer