set 1
./abc@@/main/61
./def.cpp@@/main/13
./fgh.cpp@@/main/16
./ijk.cpp@@/main/12
./mln.cpp@@/main/9
./uvw.cpp@@/main/30
set2
./eww@@/main/61
./def.cpp@@/main/13
./xxx.cpp@@/main/26
./kkk.cpp@@/main/72
./qqq.cpp@@/main/19
./fgh.cpp@@/main/16
I have two sets with filenames in above format.
need to o/p full filenames from the first set which are not present in second set.
Please note that filenames are considered similar only if they match till @@ symbol. Then only they should be considered similar.
Please guide me in this.
awk -F@ '{ if (FNR==NR) { a[$1]=0; next } if ($1 in a) { a[$1]=1 } } END { for ( i in a ) { if (a[i]==0) { print i } } }' first_file second_file
Hi
here are the input files
sett1
./cwhelper/tcwhelper.cpp@@/main/62
sett2
./cwhelper/tcwauthlatesettreqcreen.hpp@@/main/1
./cwhelper/tcwhelper.cpp@@/main/64
i have created cmp.awk as follows
#! /usr/bin/nawk -f
first_file=$1
second_file=$2
awk -F@ '{ if (FNR==NR) { a[$1]=0; next } if ($1 in a) { a[$1]=1 } } END { for ( i in a ) { if (a
[i]==0) { print i } } }' first_file second_file
running like this
./cmp.awk sett1 sett2
but getting following error
/usr/bin/nawk: syntax error at source line 5
context is
awk >>> -F@ <<<
/usr/bin/nawk: bailing out at source line 5
ivhb
December 16, 2008, 6:24am
4
remove the first line which contains "#! /usr/bin/nawk -f"
after removing the line, following errors are coming
/home/odyssey/f091018>./cmp.awk sett2 sett1
awk: syntax error near line 1
awk: illegal statement near line 1
awk: syntax error near line 1
awk: bailing out near line 1
what i pasted was a oneliner.
If you need this to keep in a file, do it as follows.
first_file=$1
second_file=$2
awk -F@ '{ if (FNR==NR) { a[$1]=0; next } if ($1 in a) { a[$1]=1 } } END { for ( i in a ) { if (a
[i]==0) { print i } } }' $first_file $second_file
look at the '$' symbol
manikantants:
what i pasted was a oneliner.
If you need this to keep in a file, do it as follows.
first_file=$1
second_file=$2
awk -F@ '{ if (FNR==NR) { a[$1]=0; next } if ($1 in a) { a[$1]=1 } } END { for ( i in a ) { if (a
[i]==0) { print i } } }' $first_file $second_file
look at the '$' symbol
Again Errors
./cmp.awk sett2 sett1
awk: syntax error near line 1
awk: illegal statement near line 1
awk: syntax error near line 1
awk: bailing out near line 1
I am using BASH . is it because of that???? please check and let me know.
am also using bash and it is working fine for me.
pls check whether awk line is broken
Its strange
all awk line is single. even then following error
/home/odyssey/f091018>./cmp.awk sett2 sett1
awk: syntax error near line 1
awk: illegal statement near line 1
awk: syntax error near line 1
awk: bailing out near line 1
are you using any line like #!/bin/bash or something.
don't know why not working for me?????
skyineyes:
Its strange
all awk line is single. even then following error
/home/odyssey/f091018>./cmp.awk sett2 sett1
awk: syntax error near line 1
awk: illegal statement near line 1
awk: syntax error near line 1
awk: bailing out near line 1
are you using any line like #!/bin/bash or something.
don't know why not working for me?????
Using following line in start
#! /usr/bin/nawk -f
first_file=$1
second_file=$2
awk -F@ '{ if (FNR==NR) { a[$1]=0; next } if ($1 in a) { a[$1]=1 } } END { for ( i in a ) { if (a
[i]==0) { print i } } }' $first_file $second_file
Errors are
/home/odyssey/f091018>./cmp.awk sett2 sett1
/usr/bin/nawk: syntax error at source line 5
context is
awk >>> -F@ <<<
/usr/bin/nawk: bailing out at source line 5
first line is not required.
Don't have any clue. Someone else has to bump.
Can you please paste your awk script and sett1 and sett2 contents???
Also the way you are using ????
sett1:
./cwhelper/tcwhelper.cpp@@/main/62
sett2:
./cwhelper/tcwauthlatesettreqcreen.hpp@@/main/1
./cwhelper/tcwhelper.cpp@@/main/64
cmp.awk:
first_file=$1
second_file=$2
awk -F@ '{ if (FNR==NR) { a[$1]=0; next } if ($1 in a) { a[$1]=1 } } END { for ( i in a ) { if (a [i]==0) { print i } } }' $first_file $second_file
./cmp.awk sett2 sett1
output:
./cwhelper/tcwauthlatesettreqcreen.hpp
manikantants:
sett1:
./cwhelper/tcwhelper.cpp@@/main/62
sett2:
./cwhelper/tcwauthlatesettreqcreen.hpp@@/main/1
./cwhelper/tcwhelper.cpp@@/main/64
cmp.awk:
first_file=$1
second_file=$2
awk -F@ '{ if (FNR==NR) { a[$1]=0; next } if ($1 in a) { a[$1]=1 } } END { for ( i in a ) { if (a [i]==0) { print i } } }' $first_file $second_file
./cmp.awk sett2 sett1
output:
./cwhelper/tcwauthlatesettreqcreen.hpp
Strange !!!!
everything same. whats the error with me ???
In other awk scripts i had used #! /usr/bin/nawk -f and they are working fine. whats the problem with this script????
please help???