Since I found this very helpful forum and friendly people, I have a small request.
I use AIX Unix and would like to know if there's a simple way how to do a kind of compare between two files. Should I use some grep, find or awk?
I have 2 text files, let's name them file1 and file2.
What I need:
I want to read line by line file1 - certain field or better 2 fields of the file1 and look up the information in the file2.
To be more descriptive: I'd like to extract field1 at position 10-15 and field2 at position 25-31 from file1 and search or find if the same information is somewhere inside the file2. When no, I'd like to output the field1 & field2 off the file1 doesn't exit in file2.
let's say file1 contains something like:
123232 3232 2323 2323123123213 trterert
and file2 e.g.
123232 3232 2323 2323123123213 XXXXXXXX
and let's say I want 123232 & trterert from file1 to be searched in file2 ==> I get an "error" because the script would find only 123232 and not trterert.....
I'd be more than happy if someone can help me out or recommend a link or appropriate command or script.
I just need to check some record(s) in one file - and if they're available in the other file...
So do I understand this correctly: if there is a line in file2 which does not contain both the information in columns 10-15 in file1, and the information in columns 20-25 in file1, then you want to print that line from file2, and additionally, any lines from file1 which did not have any such matches in file2?
Do the matches have to be from the same line in file1, or would, say columns 10-15 on line 1 and columns 20-25 on line 2 together constitute a match? (I'm guessing no, here.)
Can the matches be overlapping? Say you search for "12345" and "23456", then can the single value "123456" be considered a match on both of these fields at the same time? (I'm guessing this is okay, or doesn't matter in practice.)
Your examples don't match. Columns 10-15 in your file1 don't contain "123232" and columns 25-31 don't contain "treret". Can you come up with a correct example?
This will print non-matches from file1 to standard error and non-matches from file2 to standard output.
Using echo in backticks is always somewhat fragile if the values have significant leading or trailing whitespace. If the values you seek will not contain whitespace, this might even work, but it's hard to test without real-world samples.
Hi,
On AIX,
We have several moveplan.xml files in different folders.
I run:
find /u0/appl_top/ -name moveplan.xml -exec grep -i Passphrase {} \;
And it returns
<name>Custom Identity Keystore Passphrase File</name>
<name>Custom Trust Keystore Passphrase File</name>
... (4 Replies)
Hi,
I am running the following:
PASS="username/password"
sqlplus -s << EOF | grep -v "^$"
$PASS
set feedback off
set heading off
set termout off
select name from v\$database ;
exit
EOF
Which gives
ERROR:
ORA-28002: the password will expire within 5 days
PSMP1 (1 Reply)
Hi,
I have a number of files containing the information below.
"""""
Fundallinfo
6.3950 14.9715 14.0482
"""""
I would like to grep for Fundallinfo and use it to read the next line? I ideally would like to read the three numbers that follow in the next line and... (2 Replies)
Ok, running tsm on 2008R2, and I have the gnu awk and grep installed...I want to only capture inactive (I) files inside of the backup...I can get this to work on linux, but because windows interprets " ' ` differently, i can't get it to print out right...Here's what I have:
so basically... (8 Replies)
How can I recursively find all files in a directory and print out the file and first line number of any text blocks that match the below cases?
This would seem to involve find, xargs, *grep, regex, etc.
In summary, I want to find so-called empty "try-catch blocks" that do not contain code... (0 Replies)
Hi all ,
I'm new to unix
I have a checked project , there exists a file called xxx.config .
now my task is to find all the files in the checked out project which references to this xxx.config file.
how do i use grep or find command . (2 Replies)
Hello,
I trying to extract text that is surrounded by xml-tags. I tried this
cat tst.xml | egrep "<SERVER>.*</SERVER>" |sed -e "s/<SERVER>\(.*\)<\/SERVER>/\1/"|tr "|" " "
which works perfect, if the start-tag and the end-tag are in the same line, e.g.:
<tag1>Hello Linux-Users</tag1>
... (5 Replies)
This may just be a lack of experience talking, but I always assumed that when possible it was better to use a commands built in abilities rather than to pipe to a bunch of commands. I wrote a (very simple) script a while back that was meant to pull out a certain error code, and report back what... (4 Replies)
Hi Guys,
I need to set the value of $7 to zero in case $7 is NULL. I've tried the below command but doesn't work. Any ideas. thanks guys.
MEM=`ps v $PPID| grep -i db2 | grep -v grep| awk '{ if ( $7 ~ " " ) { print 0 } else { print $7}}' `
Harby. (4 Replies)