Sponsored Content
Operating Systems AIX Rows manupulation using AWK or sed Post 302478784 by R0H0N on Thursday 9th of December 2010 01:04:43 AM
Old 12-09-2010
Code:
#!/bin/ksh

xargs -n2 < file1.txt | while read line
do
    set `echo $line | awk -F" " '{print $1 $3}'`
    new=$1 ; full=$2
    diff=$((full - new))
    echo "Diff=$diff"
done

Explanation:
Code:
xargs -n2 < file1.txt

this will generate following output

Code:
100 A_new.txt 1000 A_full.txt
1100 B_new.txt 2000 B_full.txt
1100 C_new.txt 2000 C_full.txt

so I m reading all lines one by one and fetching 1st and 3rd value of a line separated by space. after than just echoing the diff as per your requirement.

Last edited by R0H0N; 12-09-2010 at 02:32 AM..
This User Gave Thanks to For This Post:
R0H0N
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed or awk to convert text files with recurring headings to rows and colum

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

Get text between two special rows ?( using awk or sed)?

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

get text between two special rows ?(awk or sed)?

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

Combining multiple rows in single row based on certain condition using awk or sed

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

Using sed (or awk or perl) to delete rows in a file

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

CDR manupulation

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

Awk/sed script for transposing any number of rows with header row

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

awk for string manupulation

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

Indexing each repeating pattern of rows in a column using awk/sed

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

awk or sed? rows text to co

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
XDIFF_STRING_DIFF(3)							 1						      XDIFF_STRING_DIFF(3)

xdiff_string_diff - Make unified diff of two strings

SYNOPSIS
string xdiff_string_diff (string $old_data, string $new_data, [int $context = 3], [bool $minimal = false]) DESCRIPTION
Makes an unified diff containing differences between $old_data string and $new_data string and returns it. The resulting diff is human- readable. An optional $context parameter specifies how many lines of context should be added around each change. Setting $minimal parameter to true will result in outputting the shortest patch file possible (can take a long time). PARAMETERS
o $old_data - First string with data. It acts as "old" data. o $new_data - Second string with data. It acts as "new" data. o $context - Indicates how many lines of context you want to include in the diff result. o $minimal - Set this parameter to TRUE if you want to minimalize the size of the result (can take a long time). RETURN VALUES
Returns string with resulting diff or FALSE if an internal error happened. EXAMPLES
Example #1 xdiff_string_diff(3) example The following code makes unified diff of two articles. <?php $old_article = file_get_contents('./old_article.txt'); $new_article = $_REQUEST['article']; /* Let's say that someone pasted a new article to html form */ $diff = xdiff_string_diff($old_article, $new_article, 1); if (is_string($diff)) { echo "Differences between two articles: "; echo $diff; } ?> NOTES
Note This function doesn't work well with binary strings. To make diff of binary strings use xdiff_string_bdiff(3)/xdiff_string_rabd- iff(3). SEE ALSO
xdiff_string_patch(3). PHP Documentation Group XDIFF_STRING_DIFF(3)
All times are GMT -4. The time now is 07:30 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy