Using sed how can I delete all lines from a text file except the ones that contain…
- User
Using sed how can I delete all lines from a text file except the ones that contain 'https://github' ?
Assistant
To delete all lines except the ones containing "https://github", you can use this sed command:
codesed -i '/https:\/\/github/!d' file.txtLet's break this down:
sed -iedits the file in-place instead of printing to stdout/https:\/\/github/!d- this is the address to match.!dmeans delete lines that DO NOT match this address- So this deletes all lines that do not contain "https://github"
An alternative is:
codesed -n '/https:\/\/github/p' file.txt > new.txt
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.