Sponsored Content
Top Forums Shell Programming and Scripting Grep for an exact match in a file Post 303000425 by Ads89 on Wednesday 12th of July 2017 04:50:41 AM
Old 07-12-2017
Hi Rudi - The problem is that the word I am grepping for, doesnt exist in the file - It is returning 0 when it should actually return 1. From command line it works as expected, but when put into the script it returns with 0.

Below is the code that is being used - Because $TRIM_FILENAME does not exist in $Valid_List, it should not sent the file, but it is.

Code:
 
 TRIM_FILENAME=`echo $FILENAME | sed 's,_.._$DATE,,g'`
grep -E "^${TRIM_FILENAME}$" $REFERENCE/$Valid_List
         if [ $retcode = 0 ]
        then
                echo -e "$FILENAME needs to be sent "
 
                hadoop fs -cp $line $OUTPUT_DIR
                echo "successfully sent"
        else
                echo -e "$FILENAME does not need to be sent\n"
                exit 8
        fi

 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Exact Match thru grep ?????

hey..... i do have text where the contents are like as follows, FILE_TYPE_NUM_01=FILE_TYPE=01|FILE_DESC=Periodic|FILE_SCHDL_TYPE=Daily|FILE_SCHDL=|FILE_SCHDL_TIME=9:00am|RESULTS=B FILE_TYPE_NUM_02=FILE_TYPE=02|FILE_DESC=NCTO|FILE_SCHDL_TYPE=Daily|FILE_SCHDL=|FILE_SCHDL_TIME=9:00am|RESULTS=M... (2 Replies)
Discussion started by: manas_ranjan
2 Replies

2. Shell Programming and Scripting

Using grep returns partial matches, I need to get an exact match or nothing

I’m trying to modify someone perl script to fix a bug. The piece of code checks that the zone name you want to add is unique. However, when the code runs, it finds a partial match using grep, and decides it already exists, so the “create” command exits. $cstatus = `${ZADM} list -vic | grep... (3 Replies)
Discussion started by: TKD
3 Replies

3. Solaris

grep exact match

Hi This time I'm trying to grep for an exact match e.g cat.dog.horse.cow.bird.pig horse.dog.pig pig.cat.horse.dog horse dog dog pig.dog pig.dog.bird how do I grep for dog only so that a wc -l would result 2 in above case. Thanks in advance ---------- Post updated at 06:33 AM... (4 Replies)
Discussion started by: rob171171
4 Replies

4. UNIX for Dummies Questions & Answers

grep and sed exact match questions

This was mistaken as homework in a different forum, but is not. These are questions that are close to what I am trying to do at work. QUESTION1: How do you grep only an exact string. I am using Solaris10 and do not have any GNU products installed. Contents of car.txt CAR1_KEY0 CAR1_KEY1... (1 Reply)
Discussion started by: thibodc
1 Replies

5. Shell Programming and Scripting

grep and sed exact match questions

This post was previously mistaken for homework, but is actually a small piece of what I working on at work. Please answer if you can. QUESTION1 How do you grep only an exact string. I am using Solaris10 and do not have any GNU products installed. Contents of car.txt CAR1_KEY0 CAR1_KEY1... (2 Replies)
Discussion started by: thibodc
2 Replies

6. Shell Programming and Scripting

Grep two words with exact match

HI Input : Counters Counter Int Ints Counters Counters Ints Ints I want to grep Counter|Int Output : Counter (1 Reply)
Discussion started by: pareshkp
1 Replies

7. Shell Programming and Scripting

Searching for exact match using grep

I am searching for an exact match on a value read from another file to lookup an email address in another file. The file being checked is called "contacts" and it has Act #, email address, and contact person. 1693;abc1693@yahoo.comt;Tommy D 6423;abc6423@yahoo.comt;Jim Doran... (2 Replies)
Discussion started by: ziggy6
2 Replies

8. Shell Programming and Scripting

Grep multiple exact match, do not display lines

Hi, Need help to grep the following from a file x. I just want to grep exact match not lines and not partial word. CONFSUCCESS CONFFAIL CONFPARTIALSUCCESS >cat x xczxczxczc zczczcxx CONFSUCCESS czczczcczc czxxczxzxczcczc CONFFAIL xczxczcxcczczc zczczczcz CONFPARTIALSUCCESS czczxcxzc ... (4 Replies)
Discussion started by: rajeshwebspere
4 Replies

9. Shell Programming and Scripting

Grep or sed - printing line only with exact match

Hello. In my script, some command return : q | kernel-default | package | 3.19.0-1.1.g8a7d5f9 | x86_64 | openSUSE-13.2-Kernel_stable_standard | kernel-default | package | 3.19.0-1.1.g8a7d5f9 | i586 | openSUSE-13.2-Kernel_stable_standard | kernel-default ... (3 Replies)
Discussion started by: jcdole
3 Replies

10. Shell Programming and Scripting

Grep exact match

Hello! I have 2 files named tacs.tmp and tacDB.txt tacs.tmp looks like this 0 10235647 102700 106800 107200 1105700 tacDB.txt looks like this 100100,Mitsubishi,G410,Handheld,,0,0,0 100200,Siemens,A53,Handheld,,0,0,0 100300,Sony Ericsson,TBD (AAB-1880030-BV),Handheld,,0,0,0... (2 Replies)
Discussion started by: Cludgie
2 Replies
AUSYSCALL:(8)						  System Administration Utilities					     AUSYSCALL:(8)

NAME
ausyscall - a program that allows mapping syscall names and numbers SYNOPSIS
ausyscall [arch] name | number | --dump | --exact DESCRIPTION
ausyscall is a program that prints out the mapping from syscall name to number and reverse for the given arch. The arch can be anything returned by `uname -m`. If arch is not given, the program will take a guess based on the running image. You may give the syscall name or number and it will find the opposite. You can also dump the whole table with the --dump option. By default a syscall name lookup will be a substring match meaning that it will try to match all occurrences of the given name with syscalls. So giving a name of chown will match both fchown and chown as any other syscall with chown in its name. If this behavior is not desired, pass the --exact flag and it will do an exact string match. This program can be used to verify syscall numbers on a biarch platform for rule optimization. For example, suppose you had an auditctl rule: -a always, exit -S open -F exit=-EPERM -k fail-open If you wanted to verify that both 32 and 64 bit programs would be audited, run "ausyscall i386 open" and then "ausyscall x86_64 open". Look at the returned numbers. If they are different, you will have to write two auditctl rules to get complete coverage. -a always,exit -F arch=b32 -S open -F exit=-EPERM -k fail-open -a always,exit -F arch=b64 -S open -F exit=-EPERM -k fail-open For more information about a specific syscall, use the man program and pass the number 2 as an argument to make sure that you get the syscall information rather than a shell script program or glibc function call of the same name. For example, if you wanted to learn about the open syscall, type: man 2 open. OPTIONS
--dump Print all syscalls for the given arch --exact Instead of doing a partial word match, match the given syscall name exactly. SEE ALSO
ausearch(8), auditctl(8). AUTHOR
Steve Grubb Red Hat Nov 2008 AUSYSCALL:(8)
All times are GMT -4. The time now is 01:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy