-
-
Notifications
You must be signed in to change notification settings - Fork 88
Sheffield | 25-SDC-Nov | Hassan Osman | Sprint 1 | Individual Shell Tools #199
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 30 commits
f1e23c6
24c2644
fcc4083
cac0060
f6b7696
9e1bd4e
83b4ee5
be27632
4a19420
a299f58
1369586
10c6a0a
674dbea
63aa039
6809ece
606d1e3
8634165
fdd8d30
51205e9
75b2d18
cd1a10b
0449dd7
e88decc
b448466
f06a678
9c1dff5
f02095d
9a69374
b79b2a4
89e879b
25db0ac
19e1227
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,5 @@ 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. Thank you! I now understand that [[:space:]] had complicated my code as it handle complex cases where a line contains multiple white spaces at different spots within. The code as now been simplified for your review. :) |
||
|
|
||
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.
This works, but remember what the default separator is. If it is unchanged, you don't need to use that option.
Uh oh!
There was an error while loading. Please reload this page.
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.
Hello, thanks for the feedback and apologies for the delayed response. Well, I now know that awk tool splits on spaces by default. So this bit here "-F' '" is basically redundant. I've simplified my solution now :)