Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7757207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:01:40+00:00 2026-06-01T13:01:40+00:00

My sed only works if the input file last entry is ‘in’, how would

  • 0

My sed only works if the input file last entry is ‘in’, how would I get it to work if file has ‘in’ or ‘out’? I’ve tried different variations with no success.

egrep -w 'TCP|UDP' denied.txt | sed 's/:[^:]* in/ in/'
egrep -w 'TCP|UDP' denied.txt | sed 's/:[^:]* in/ in/ out/ out/'
egrep -w 'TCP|UDP' denied.txt | sed 's/:[^:]* in/ in/ || out/ out/'

input file

Apr 6 08:54:23 TCP 212.58.244.58:80 in

Apr 6 09:29:09 TCP 212.58.244.58:443 out
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T13:01:41+00:00Added an answer on June 1, 2026 at 1:01 pm

    Try with:

    egrep -w 'TCP|UDP' denied.txt | sed 's/:[^:]* \(in\|out\)/ \1/'
    

    See sed regular expressions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to parse log files, I need to get only last IP
I have a string test:growTest:ret And with sed i would to delete only test:
I've tried this on multiple small files, everything works fine. But when testing sed
bash-3.2$ sed -i.bakkk -e s#/sa/#/he/#g .* sed: .: in-place editing only works for regular
Using only grep and sed, is there a way I can tranform the output
UPDATED: Using sed, how can I insert (NOT SUBSTITUTE) a new line on only
GNU sed version 4.1.5 seems to fail with International chars. Here is my input
I'm trying to do my homework that is restricted to only using sed to
I am trying to get show hide to work on multiple objects but I
To prefix unique words with UNIQUE: inside a file I've tried to use a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.