Skip to content
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

Broken sed '/*/p' #23

Closed
jwilk opened this issue Jun 5, 2023 · 4 comments
Closed

Broken sed '/*/p' #23

jwilk opened this issue Jun 5, 2023 · 4 comments

Comments

@jwilk
Copy link
Collaborator

jwilk commented Jun 5, 2023

In #1, @Doctor-love added

sed '/*/p' file.txt

But this duplicates lines containing the * character. E.g.:

$ printf '*hello*\nworld!\n' > file.txt
$ cat file.txt
*hello*
world!
$ sed '/*/p' file.txt
*hello*
*hello*
world!

There's now another sed call that is shorter and works correctly, so IMHO this one should be removed.

@magisterquis
Copy link
Contributor

With BSD sed, at least, sed '' file.txt works as well.

xyproto added a commit to xyproto/catgolf that referenced this issue Jun 6, 2023
@jwilk
Copy link
Collaborator Author

jwilk commented Jun 6, 2023

With BSD sed, at least, sed '' file.txt works as well.

Yup, that should work with any sed. (Successfuly tested with GNU sed and Plan 9 sed).

xyproto added a commit to xyproto/catgolf that referenced this issue Jun 6, 2023
@jwilk
Copy link
Collaborator Author

jwilk commented Jun 7, 2023

sed '' file.txt

sed t file.txt is one character shorter. (Or longer, depending on how you count…)

@Doctor-love
Copy link
Contributor

Agree!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants