12-09-2010
Rows manupulation using AWK or sed
Hi Everyon,
I am stuck in a script.I have a file named file1.txt as given below:
It contains 2 columns-count and filename.
cat file1.txt
count filename
100 A_new.txt
1000 A_full.txt
1100 B_new.txt
2000 B_full.txt
1100 C_new.txt
2000 C_full.txt
...................
..................
I want to subtract first field of row1 and row2 and store a result in a
variable say "diff". Then
I want to subtract first field of row3 and row4 and store a result in the
variable say "diff". Similary...for rows 5 and 6 and soon......
I am using kshell. I know I have to use AWK or sed but dont know how to.
Any help is apreciated.
Regards,
raj
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I have many text file reports generated by a Information Assurance tool that I need to get into a .CSV format or Excel tab delimited format. I want to use sed or awk to grab all the information in the sample text file below and create column headings:Risk ID, Risk Level, Category, Description, How... (5 Replies)
Discussion started by: Bjoeboo
5 Replies
2. Shell Programming and Scripting
Hi Friends
I am facing some problem in extract the lines between two fixed lines
for examplemy text file look like ...
--------
line 1
line 2
line 3
---------
line 4
line 5
--------
line 6
line 7
line 8
line 9
line 10
---------
now i want the data between "-------" these... (4 Replies)
Discussion started by: sushantnirwan
4 Replies
3. Shell Programming and Scripting
Hello,
I've the follwing text:
gfdgfg
--------------------------------
dfgfdgdfg
fdgfdgfdgdgf
fdgf
------------------------------
f
g
gdgf
a constant string that i know
---------------------------------------------
data I want to have data I want to have
data I want to have data I... (16 Replies)
Discussion started by: eric_
16 Replies
4. Shell Programming and Scripting
Hi,
I'm using AIX(ksh shell).
> cat temp.txt
"a","b",0
"c",bc",0
"a1","b1",0
"cc","cb",1
"cc","b2",1
"bb","bc",2
I want the output as:
"a","b","c","bc","a1","b1"
"cc","cb","cc","b2"
"bb","bc"
I want to combine multiple lines into single line where third column is same.
Is... (1 Reply)
Discussion started by: samuelray
1 Replies
5. Shell Programming and Scripting
I have a Unix file with 200,000 records, and need to remove all records from the file that have the character ‘I' in position 68 (68 bytes from the left). I have searched for similar problems and it appears that it would be possible with sed, awk or perl but I do not know enough about any of these... (7 Replies)
Discussion started by: joddo
7 Replies
6. Shell Programming and Scripting
Hello Friends,
I need to examine a huge CDR file according to a complex (at least for me) condition like below and i couldnt write anything :(
In CDR file there are more than hundreds of fields, I need to print the rows which matches the below condition:
while $13 field of subsequent... (9 Replies)
Discussion started by: EAGL€
9 Replies
7. Shell Programming and Scripting
Greetings!
I have been trying to find out a way to take a CSV file with a large number of rows, and a very large number of columns (in the thousands) and convert the rows to a single column of data, where the first row is a header representing the attribute name and the subsequent series of... (3 Replies)
Discussion started by: tntelle
3 Replies
8. Shell Programming and Scripting
Hi All,
I have one file with two columns separated by tab.
I need to search for second column value of this file in the 5 column of another file. If the match is found replace the 5th column of second file with entire row of the first file.
e.g.
file1
123 D.abc
234 D.rde
4563 ... (2 Replies)
Discussion started by: alok2082
2 Replies
9. Shell Programming and Scripting
Hello All,
I have data like this in a column.
0
1
2
3
0
3
4
5
6
0
1
2
3
etc. where 0 identifies the start of a pattern in my data.
So I need the output like below using either awk/sed.
0 1 (2 Replies)
Discussion started by: ks_reddy
2 Replies
10. Shell Programming and Scripting
Hello Friends!
I would like to help the masters ... I have a file with the entry below and would like a script for that output:
Input file:
001 1 01-20152142711532-24S 1637909825/05/2015BAHIA SERVICOS R F, ... (1 Reply)
Discussion started by: He2
1 Replies
LEARN ABOUT DEBIAN
sc_tracediff
SC_TRACEDIFF(1) BSD General Commands Manual SC_TRACEDIFF(1)
NAME
sc_tracediff -- display traceroute paths where the path has changed.
SYNOPSIS
sc_tracediff [-a] [-m method] [-n] file1.warts file2.warts
DESCRIPTION
The sc_tracediff utility displays pairs of traceroutes to a destination where the path has changed. It takes two warts files as input and
displays paths where a hop differs by its address. The options are as follows:
-a dump all traceroute pairs regardless of whether they have changed.
-m method
specifies the method used to match pairs of traceroutes together. If dst is specified, traceroutes are matched if the destination IP
address of both traces are the same. If userid is specified, traceroutes are matched if the userid field of both traces are the
same. If dstuserid is specified, traceroutes are matched if the destination IP address and userid fields are the same. By default,
the destination IP address is used.
-n names should be reported instead of IP addresses, where possible.
sc_tracediff can be useful in network monitoring to identify when a forward IP path has changed. In this scenario, it is recommended that
Paris traceroute is used with the same UDP source and destination ports for each execution of scamper so that only paths that have changed
are identified, not merely alternate paths visible due to per-flow load-balancing. By default scamper uses a source port based on the
process ID, which will change with each execution of scamper.
EXAMPLES
The command:
scamper -O warts -o file1.warts -c 'trace -P udp-paris -s 31337' -f list.txt
collects the forward IP paths towards a set of IP addresses found in list.txt using 31337 as the UDP source port value. If the above command
is adjusted to subsequently collect file2.warts, then we can identify paths that have subsequently changed with the command:
sc_tracediff file1.warts file2.warts
If Paris traceroute with ICMP probes is preferred, then the following invocation of scamper is appropriate:
scamper -O warts -o file1.warts -c 'trace -P icmp-paris -d 31337' -f list.txt
In this case, scamper uses 31337 as the ICMP checksum value in each probe.
SEE ALSO
scamper(1),
B. Augustin, X. Cuvellier, B. Orgogozo, F. Viger, T. Friedman, M. Latapy, C. Magnien, and R. Teixeira, Avoiding traceroute anomalies with
Paris traceroute, Proc. ACM/SIGCOMM Internet Measurement Conference 2006.
AUTHOR
sc_tracediff is written by Matthew Luckie <mjl@luckie.org.nz>.
BSD
April 21, 2011 BSD