Hi
Am having 2 files
1st file having
1 2 3 4 5 6 7 8 9
2nd file
1
2
b
3
c
i want to check eache character in 2nd file is present or not
need to check whether 1 is present in 1st file
rec=`cat 2nd file`
for i in $rec
if [ $i = 1st file (how to check using array concept?
So your 1st file has only 1 row? if yes..
awk 'NR==FNR{v=$0;next}
v ~ $0{print $0"exists in 1st file"}' 1stfile 2ndfile
i want to print he character which is not present in the 1st file
change it as below..
awk 'NR==FNR{v=$0;next}
v !~ $0{print $0"exists in 1st file"}' 1stfile 2ndfile
Jotne
5
A small correction
awk 'NR==FNR{v=$0;next}
v !~ $0{print $0,"exists not in 1st file"}' 1stfile 2ndfile
b exists not in 1st file
c exists not in 1st file
hi jote
thank you
i want to execute in loop i need the condition like
if a in (2nd file a b c d.....)
then
echo string is correct
else echo string in not in 2nd file
fi
Is there any specific reason for loop? I guess awk fits the purpose (as per your details). Are we missing anything here?
yes
am writing a script to identify whether the string is present or not
for example
consider a record
abcd,1234,xyz
i need to validate whether the first column delimeter as , abc
is present in the array (a b c d e f)
if it is present then no issue else i need to print tha string
---------- Post updated at 06:33 AM ---------- Previous update was at 06:05 AM ----------
yes
i need to find the character which is nt present there will be many records
The delimiter , will never be present in the array (a b c d e f). I'm not sure what you were expecting.