Find the answer to your Linux question:
Results 1 to 5 of 5
Hi there, suppose I have a line that looks like this: Code: 13:47:54.830735 192.168.168.65.54487 85.214.141.246.80: 336 and I want it to look like that: Code: 13:47:54 192.168.168.65 85.214.141.246 336 The ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Feb 2011
    Posts
    4

    Question little help with bash line formatting needed


    Hi there,

    suppose I have a line that looks like this:

    Code:
    13:47:54.830735 192.168.168.65.54487 85.214.141.246.80: 336
    and I want it to look like that:

    Code:
    13:47:54 192.168.168.65 85.214.141.246 336
    The first line is already the output of a long expression with a lot of piping and formatting with awk etc., but now I'm somehow stuck with the rest. Can you give me a clue how to achieve it? Thanks for your help!

    PS: The command that outputs the lines looks like that at the moment:
    Code:
    tcpdump -n | grep 192.168.168. | grep -v "length 0" | grep length | awk '{print $1,$3,$5,$(NF)}'

  2. #2
    Linux Engineer Kloschüssel's Avatar
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    773
    sed 's/\.[0-9]\{1,6\}[ :]\{1,2\}/ /g' file
    Last edited by Kloschüssel; 02-02-2011 at 01:14 PM.

  3. #3
    Just Joined!
    Join Date
    Feb 2011
    Posts
    4
    It works perfectly Thanks, that was fast!

    Cheers, Rob

  4. #4
    Linux Newbie
    Join Date
    Apr 2010
    Location
    Novosibirsk, Russia
    Posts
    145
    Advanced Bash Scripting Guide

    I suppose it would be helpful to you in such cases )

  5. #5
    Linux Engineer Kloschüssel's Avatar
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    773
    +1 Schmidt

    Please try to learn something out of my example and close the thread if you believe your question was answered.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •