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 6995805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:04:35+00:00 2026-05-27T20:04:35+00:00

I have a pcap file as input and I want to get particular strings

  • 0

I have a pcap file as input and I want to get particular strings from the file. I used the following command:-

/home/rahul/vPath-dissector/binaries/wireshark-1.6.1/bin/tshark -r /home/rahul/Downloads/abc.pcap -V -x -O FTP | grep '^[0-9]\{4\}'

then I got the following output:-

0000  08 00 27 8f 99 c4 08 00 27 f3 90 1f 08 00 45 10   ..'.....'.....E.
0010  00 34 46 1d 40 00 40 06 5f 31 c0 a8 0a 0a c0 a8   .4F.@.@._1......
0020  0a 0b 00 15 89 56 1d 37 75 c6 8a df 8e c3 80 11   .....V.7u.......
0030  00 b5 9a 9d 00 00 01 01 08 0a 00 15 41 94 01 bb   ............A...
0040  cc 93                                             ..


0000  08 00 27 f3 90 1f 08 00 27 8f 99 c4 08 00 45 10   ..'.....'.....E.
0010  00 34 33 e0 40 00 40 06 71 6e c0 a8 0a 0b c0 a8   .43.@.@.qn......
0020  0a 0a 89 56 00 15 8a df 8e c3 1d 37 75 c7 80 10   ...V.......7u...
0030  00 5c 9a f5 00 00 01 01 08 0a 01 bb cc 94 00 15   .\..............
0040  41 94                                             A.

I want the output as:-

08 00 27 8f 99 c4 08 00 27 f3 90 1f 08 00 45 10
00 34 46 1d 40 00 40 06 5f 31 c0 a8 0a 0a c0 a8
0a 0b 00 15 89 56 1d 37 75 c6 8a df 8e c3 80 11
00 b5 9a 9d 00 00 01 01 08 0a 00 15 41 94 01 bb
cc 93  


08 00 27 f3 90 1f 08 00 27 8f 99 c4 08 00 45 10
00 34 33 e0 40 00 40 06 71 6e c0 a8 0a 0b c0 a8
0a 0a 89 56 00 15 8a df 8e c3 1d 37 75 c7 80 10
00 5c 9a f5 00 00 01 01 08 0a 01 bb cc 94 00 15
41 94

If I print the strings upto $18 or so using awk, then I get problem with the last line, because in some packets its less than the fixed length and so it gives the other strings as well which I don’t want.

Note:-
Between 00X0 and XX, there are two blank spaces and between the random string at end, there are three spaces.

So, I want string upto those three blank spaces, not rest after them….

Kindly help me with an awk expression which will give me the output as specified by me….

  • 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-05-27T20:04:35+00:00Added an answer on May 27, 2026 at 8:04 pm

    Easy, try this:

     awk -F'  +' '{print $2}' ./infile
    

    Output

    $ awk -F'  +' '{print $2}' ./infile
    08 00 27 8f 99 c4 08 00 27 f3 90 1f 08 00 45 10
    00 34 46 1d 40 00 40 06 5f 31 c0 a8 0a 0a c0 a8
    0a 0b 00 15 89 56 1d 37 75 c6 8a df 8e c3 80 11
    00 b5 9a 9d 00 00 01 01 08 0a 00 15 41 94 01 bb
    cc 93
    
    
    08 00 27 f3 90 1f 08 00 27 8f 99 c4 08 00 45 10
    00 34 33 e0 40 00 40 06 71 6e c0 a8 0a 0b c0 a8
    0a 0a 89 56 00 15 8a df 8e c3 1d 37 75 c7 80 10
    00 5c 9a f5 00 00 01 01 08 0a 01 bb cc 94 00 15
    

    Note:
    If you have gawk, you can remove the grep command entirely and roll it into awk like so

    awk --re-interval -F'  +' '/^[0-9]{4}/{print $2}' ./infile
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some network traffic captured pcap file and want to send its packets
I want to parse only RTP packets from a .pcap file generated from WireShark
I'm making a program to calculate latency from a tcpdump/pcap file and I want
Have you managed to get Aptana Studio debugging to work? I tried following this,
#I used to have this, but I don't want to write to the disk
I have a program which generates its own Wireshark pcap-file (sort of a network
Does pcap_t *pcap_open_offline(const char *fname, char *errbuf) from libpcap read the whole pcap file
I have pcap file that contains RTP data which in turn is audio for
Does anyone know of a tool that will take a PCAP file as input
i am using pcap to create a packet sniffer. i have this tcp structure:

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.