Skip to content
TheChatArchiveThe Chat Archive
gpt-4o-mini-2024-07-18· OpenAIAi2 WildChat-4.8M (AI2)

how to filter out lines from file with sed which doesn't contain @ simbol

  1. User

    how to filter out lines from file with sed which doesn't contain @ simbol

  2. Assistant

    You can use the sed command to filter out lines from a file that do not contain the @ symbol. The following command will do just that:

    sed -n '/@/p' filename
    

    Here’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 that sed will search for; it represents lines that contain the @ symbol.
    • p: This command tells sed to print the lines that match the pattern.

    Replace filename with 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.txt
    

    This command will save the filtered lines to output.txt.