Operating System - HP-UX
1748166 Members
3609 Online
108758 Solutions
New Discussion юеВ

Re: a small awk question (Newbie)

 
SOLVED
Go to solution
Daehnrich
Occasional Advisor

a small awk question (Newbie)

Hello,

i have 2 Files,

in File1 (find /etc/rc.config.d -type f -exec ls -l {} \; >file1)

are files without backslash,

in File2 (find /etc/rc.config.d -type f -exec ls -lb {} \; >file2)

are files with backslash.

How can i different interfacial the 2 files with awk to decide.

I need only the Files with \.

Thx.

regards

S.D.
7 REPLIES 7
Tom Geudens
Honored Contributor

Re: a small awk question (Newbie)

Hi,
I might have misunderstood the question, but wouldn't "diff" give you the difference between the two files ?

Regards,
Tom
A life ? Cool ! Where can I download one of those from ?
Daehnrich
Occasional Advisor

Re: a small awk question (Newbie)

hi,

diff is not enough accurate.

diff file1 file2 =

# diff file1 file2
49c49
< -rw-rw-rw- 1 root sys 0 Aug 19 18:52 /etc/rc.config.d/
---
> -rw-rw-rw- 1 root sys 0 Aug 19 18:52 /etc/rc.config.d/\001
51c51,52
< -rw-rw-rw- 1 root sys 4137 Aug 27 08:58 /etc/rc.config.d/file1
---
> -rw-rw-rw- 1 root sys 4218 Aug 27 08:58 /etc/rc.config.d/file1
> -rw-rw-rw- 1 root sys 4221 Aug 27 08:58 /etc/rc.config.d/file2


I need only the the line with the File \001 the file has nonprintable charakters.

You understand my Question? :)

regards S??ren
Leif Halvarsson_2
Honored Contributor

Re: a small awk question (Newbie)

Hi

To grep lines with \ in:
grep '\\' filename

Daehnrich
Occasional Advisor

Re: a small awk question (Newbie)

oh, ok. the answer is good, but my preceptor to claim awk.

thanks

S??ren
Leif Halvarsson_2
Honored Contributor
Solution

Re: a small awk question (Newbie)

Hi

Or if you want to use awk you can use the octal value for matching:
$1 ~ /\0134/ { print }

Replace $1 with the parameter you want to match on.
Steve Steel
Honored Contributor

Re: a small awk question (Newbie)

Hi

Try comm

NAME
comm - select or reject lines common to two sorted files

SYNOPSIS
comm [-[123]] file1 file2

DESCRIPTION
comm reads file1 and file2, which should be ordered in increasing
collating sequence (see sort(1) and Environment Variables below), and
produces a three-column output:

Column 1: Lines that appear only in file1,
Column 2: Lines that appear only in file2,
Column 3: Lines that appear in both files.

Steve steel
If you want truly to understand something, try to change it. (Kurt Lewin)
Brian Kinney
Frequent Advisor

Re: a small awk question (Newbie)

Finding all entries with a "\" embedded:

find /etc/rc.config.d -type f -exec ls -lb {} \; | awk '$0~/\\/{print $0}'

"Any sufficiently advanced technology can be indistinguishable from magic" Arthur C. Clarke. My corollary - "Any advanced technology can be crushed with a sufficently large enough rock."