Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Assistance required to decode sed search using /1 Post 303035611 by sand1234 on Wednesday 29th of May 2019 10:07:19 AM
Old 05-29-2019
Assistance required to decode sed search using /1

Hi,

I am trying to extract line number (first number), as well as everything from TSVal onwards.

Code:
 4   1.474005 172.18.124.142 -> 74.125.228.46 TCP 2450940617 74 44021 > https [SYN] Seq=0 Win=5840 Len=0 MSS=1380 SACK_PERM=1 TSval=2450940617 TSecr=0 WS=64
  6   1.488149 172.18.124.142 -> 74.125.228.46 TCP 2450940637 66 44021 > https [ACK] Seq=1 Ack=1 Win=5888 Len=0 TSval=2450940637 TSecr=1834617706

The following sed regex accomplishes this, but I have a few questions around the expression.

Code:
$ cat tcp_timestamps.txt | sed 's/\([0-9]\) .*TSval/\1 TSval/'
 4 TSval=2450940617 TSecr=0 WS=64
  6 TSval=2450940637 TSecr=1834617706

1> Why does [0-9] need to be grouped into brackers?
2> What is the purpose of \1 TSval? If /1 denotes the last element which is remembered, how does it apply here?

Thanks,
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed search and replace word assistance...

Hi, I am trying to write a shell script designed to take input line by line by line from a file with a word on each line for editing with sed. Example file: 1.ejverything 2.bllown 3.maikling 4.manegement 5.existjing 6.systems My design currently takes input from the user, and... (2 Replies)
Discussion started by: mkfitzwilliams
2 Replies

2. Shell Programming and Scripting

DECODE file field is required in Bash

Dear All, I want to decode the one of the file field. Input file: 9393939393|999|2009-02-20 00:00:01|2||4587|2007-02-28 00:00:01|0 9393939393|2001|2009-02-20 00:00:01|2||4587|2007-02-28 00:00:01|0 9393939393|1500|2009-02-20 00:00:01|2||4587| 2007-02-28 00:00:01|0... (1 Reply)
Discussion started by: hanu_oracle
1 Replies

3. Emergency UNIX and Linux Support

Complicated SED search required

Hi All, I'm trying to extract all the description fields from a MIB file which contain multiple instances of the following text: ENTERPRISE compaq VARIABLES { sysName, cpqHoTrapFlags, cpqSsBoxCntlrHwLocation, cpqSsBoxCntlrIndex, cpqSsBoxBusIndex,... (10 Replies)
Discussion started by: badoshi
10 Replies

4. Shell Programming and Scripting

Decode %s Special Character in Sed

Greetings, I am doing something that I don't know if it is possible... I have a file with a line looks like this: <%s \n%s / %s \n%s \n> and I am trying to replace this line with <%s \n%s \n%s / %s \n%s \n> in Shell script with sed command... StringToReplace='%s \n%s / %s \n%s \n'... (2 Replies)
Discussion started by: wasabihowdi
2 Replies

5. Shell Programming and Scripting

Logic Test Search Assistance

I need to create a logical test to see if a job is complete. I have 4 seperate jobs that will be running in tandem and will create a file indicating the job completed. Once all 4 jobs have completed I will need to execute the final job to execute the final task. The problem I am having is that... (5 Replies)
Discussion started by: NoMadBanker
5 Replies

6. UNIX for Advanced & Expert Users

Need assistance with sed

Hi All, I need your assistance, I would like to replace all lines beginning with the word "begin" with the below text: Device | IPMB0-A | IPMB0-B Board Address |Sent SentErr %Errr |Sent SentErr ... (10 Replies)
Discussion started by: Dendany83
10 Replies

7. Shell Programming and Scripting

Assistance Required - manipulating records

Hi guys, I need to do a bit of work to a file. Basically I want to run a SQL statement against each record in this file (hundreds of lines): sample input: 233333 233334 233335 233336 I want to do the following: 1. Add a some text at the beginning to prepare the SQL (3 lines) 2. Add... (7 Replies)
Discussion started by: mcclunyboy
7 Replies

8. Hardware

Assistance required when booting M3000, error shows; * MBU_A Status:Degraded; Ver:0701h; Serial:

Here is the error showing in the XCSF, can anyone recommend further diagnosis for this specific error?; XSCF> showhardconf SPARC Enterprise M3000; + Serial:PX61142029; Operator_Panel_Switch:Locked; + Power_Supply_System:Single; SCF-ID:XSCF#0; + System_Power:On;... (4 Replies)
Discussion started by: Touchpoint
4 Replies

9. Shell Programming and Scripting

Assistance required with awk and regular expressions

Hello there, I am trying to get my head around the section below of a script we use that incorporates AWK and Regular Expressions. { match($0,"The broker*");print $1,$2,$3 ":", substr($0, RSTART,RLENGTH)} I have a basic understanding of how match works, what I am struggling with is the... (2 Replies)
Discussion started by: jimbojames
2 Replies

10. Shell Programming and Scripting

sed assistance

Hello everyone. I am trying to replace sprintf(buffer, "{\"id\":1,\"method\":\"mining.update_block\",\"params\":}\n", coinid, blockhash); with sprintf(buffer, "{\"id\":1,\"method\":\"mining.update_block\",\"params\":}\n", coinid, blockhash); this is the code I was trying but is... (9 Replies)
Discussion started by: crombiecrunch
9 Replies
SHTOOL-SUBST.TMP(1)					      GNU Portable Shell Tool					       SHTOOL-SUBST.TMP(1)

NAME
shtool-subst - GNU shtool sed(1) substitution operations SYNOPSIS
shtool subst [-v|--verbose] [-t|--trace] [-n|--nop] [-w|--warning] [-q|--quiet] [-s|--stealth] [-i|--interactive] [-b|--backup ext] [-e|--exec cmd] [-f|--file cmd-file] [file] [file ...] DESCRIPTION
This command applies one or more sed(1) substitution operations to stdin or any number of files. OPTIONS
The following command line options are available. -v, --verbose Display some processing information. -t, --trace Enable the output of the essential shell commands which are executed. -n, --nop No operation mode. Actual execution of the essential shell commands which would be executed is suppressed. -w, --warning Show warning on substitution operation resulting in no content change on every file. The default is to show a warning on substitution operations resulted in no content change on all files. -q, --quiet Suppress warning on substitution operation resulting in no content change. -s, --stealth Stealth operation. Preserve timestamp on file. -i, --interactive Enter interactive mode where the user has to approve each operation. -b, --backup ext Preserve backup of original file using file name extension ext. Default is to overwrite the original file. -e, --exec cmd Specify sed(1) command directly. -f, --file cmd-file Read sed(1) command from file. EXAMPLE
# shell script shtool subst -i -e 's;(c) ([0-9]*)-2000;(c) 1-2001;' *.[ch] # RPM spec-file %install shtool subst -v -n -e 's;^(prefix=).*;1 $RPM_BUILD_ROOT%{_prefix};g' -e 's;^(sysconfdir=).*;1 $RPM_BUILD_ROOT%{_prefix}/etc;g' `find . -name Makefile -print` make install HISTORY
The GNU shtool subst command was originally written by Ralf S. Engelschall <rse@engelschall.com> in 2001 for GNU shtool. It was prompted by the need to have a uniform and convenient patching frontend to sed(1) operations in the OpenPKG package specifications. SEE ALSO
shtool(1), sed(1). 18-Jul-2008 shtool 2.0.8 SHTOOL-SUBST.TMP(1)
All times are GMT -4. The time now is 02:16 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy