gpt-4o-mini-2024-07-18· OpenAI
WildChat-4.8M (AI2)
how to filter out lines from file with sed which doesn't contain @ simbol
- User
how to filter out lines from file with sed which doesn't contain @ simbol
- Assistant
You can use the
sedcommand to filter out lines from a file that do not contain the@symbol. The following command will do just that:sed -n '/@/p' filenameHere’s a breakdown of the command:
sed: The stream editor command.-n: Suppresses automatic printing of the pattern space. This means that sed won't print anything unless explicitly told to do so./@/: This is the pattern thatsedwill search for; it represents lines that contain the@symbol.p: This command tellssedto print the lines that match the pattern.
Replace
filenamewith the actual name of your input file. The result will be the lines from the file that contain the@symbol.If you want to save the output to a new file, you can redirect the output like this:
sed -n '/@/p' filename > output.txtThis command will save the filtered lines to
output.txt.