01-13-2007
checkout this command for getting only the diff output without > 2a3
diff 2.txt 3.txt|awk 'NR==2 {print$2}'
or
diff 2.txt 3.txt|sed "1 d"|awk '{print$2}'
which ever suits your requirement
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I had to delete rows when a record was missing a field. My solution was
cut -c 202-402 ${dataFile} | awk '{if (substr($0,103,30) !~ /^ *$/) print $0} >> ${workFile}
The cut is because they came two records to a row.
Anyone want to offer a more elegant solution? (2 Replies)
Discussion started by: gillbates
2 Replies
2. UNIX for Dummies Questions & Answers
Hi,
I have a .txt file
Sample:
=====================
NEXT HOST
=====================
AEADBAS001
ip access-list extended BLA_Incoming_Filter
ip access-list extended BLA_Outgoing_Filter
access-list 1 permit xxxxxxxxxxxxxx
access-list 2 permit xxxxxxxxxxxxxx
=====================... (4 Replies)
Discussion started by: I-1
4 Replies
3. UNIX for Dummies Questions & Answers
When I use this command I get an output of some numbers
cat ac.20070511 | cut -d" " -f19
Is there any way for me to display only the numbers that are greater than 1000 but not all the numbers in the ouput.
Can any one help me with this. :) (8 Replies)
Discussion started by: venu_nbk
8 Replies
4. UNIX for Advanced & Expert Users
Hi,
I have two files say A and B, Both files have some common records few records which are unique to file A and unique to file B.
Can anyone please help me out to find the records which are present in only B
Please consider the files are of too large size.
Thanks:confused: (1 Reply)
Discussion started by: Shiv@jad
1 Replies
5. Shell Programming and Scripting
Hi All,
I've got a script to output YAML data, and I want to display data that's held inside variables inside one large CAT area. What's the easiest way to do this?
cat << "END"
---
classes:
- general_image
- $intro #Variable 1
- $mid #Variable 2
... (2 Replies)
Discussion started by: glarizza
2 Replies
6. Shell Programming and Scripting
Hello attempting to redirect out to create a startup script in solaris. The steps are working but the $1 entry is being left out. syntax below and content of output file below.
cat > S99build << EOF
> #!/bin/bash
> case $1 in
> 'start')
> /usr/os-buildsol.sh
>
> ;;
> esac
> exit 0
>... (3 Replies)
Discussion started by: juanb25
3 Replies
7. UNIX for Dummies Questions & Answers
Hi everyone.
I am a newbie to Linux stuff. I have this kind of problem which couldn't solve alone. I have a text file with records separated by empty lines like this:
ID: 20
Name: X
Age: 19
ID: 21
Name: Z
ID: 22
Email: xxx@yahoo.com
Name: Y
Age: 19
I want to grep records that... (4 Replies)
Discussion started by: Atrisa
4 Replies
8. Shell Programming and Scripting
Hi,
I have thousands of data in 1 file that need to be sorted out. My file is like below:-
File1.txt
condition 1
scaf_27 CDS 48317 48517 "e_gww2.27.12.1" Id 35277
scaf_27 stop_cod 48317 48319 "e_gww2.27.12.1"
scaf_27 CDS 48518 49107 "e_gww2.27.12.1" ... (4 Replies)
Discussion started by: redse171
4 Replies
9. Shell Programming and Scripting
I have a script to do a couple simple but repetitive commands on files that are provided to us. One of the things is to get rid of the line feeds. This is the section that is causing problems, i even cut this section into its own file to make sure nothing else was affecting it.
#!/usr/bin/bash... (4 Replies)
Discussion started by: oly_r
4 Replies
10. Shell Programming and Scripting
I have a fixed width file. The records looks something similar to below:
Type ID SSN NAME .....AND SOME MORE FIELDS
A1 1234 .....
A1 1234 .....
B1 1234 .....
M2 4567 .....
M2 4567 .....
N2 4567 .....
N2 4567 .....
A1 9999
N2 9999
Now if A1 is present then B1 has to be present.... (2 Replies)
Discussion started by: Saanvi1
2 Replies
LEARN ABOUT PHP
xdiff_string_diff
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)