Sponsored Content
Top Forums Shell Programming and Scripting Do nothing if column1 is found Post 302959238 by baris35 on Friday 30th of October 2015 12:53:07 PM
Old 10-30-2015
Do nothing if column1 is found

Hello,
I have stucked at one point.
When I run the script, I am asking the script to search in database file and if it's found, do nothing and proceed to next line in database file.

Code:
#!/bin/bash
./extract_email.pl output2 > database
while read -r COL1
    X=$(grep $COL1 database )
    if [[ -z $X ]] ; then
        echo "false"
        exit
else 
do
sed -n '1,2p' /var/test/test.txt > $COL1
sed -e '1,2d' /var/test/test.txt > /var/test/test2.txt
mail -s "mail subject is here" -a "From: info@mymail.net" $COL1 < $COL1
mv $COL1 /var/test/database_pool/
done < database
rm output*
rm *.host
exit 0

when i run the script, it says " syntax error near unexpected token `do' "

Could you please let me know how "do nothing" if col1 is already in my database.

Thanks in advance
Boris

Last edited by baris35; 10-30-2015 at 04:23 PM.. Reason: [solved]
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

only if column1 equals this print that

I have text file with hundreds of lines, space delimited, each line has the same amount of "columns" and the same amount of characters in each, Column 1, Column 2, and Column 3. I need a script that will print all columns of the "current" line along with the last two columns of the next line ONLY... (3 Replies)
Discussion started by: ajp7701
3 Replies

2. Shell Programming and Scripting

awk - replacing stings in file1 with column1 in file2

Hello, I've never used awk before, but from what I've read, it will best suit what I'm trying to do. I have 2 files. I need to replace strings in file1 with the first column of a matching string in file2. Below are examples: File1: random-string1 1112 1232 3213 2131 random-string2... (7 Replies)
Discussion started by: upstate_boy
7 Replies

3. Shell Programming and Scripting

delete a string on column1

Hi I have a file with multiple columns. But there is something weird on column one that is attached to the name. The good thing is that its a consistent pattern so there should be a way to remove it. So the first column looks something like this: name_345.4ml date_3456.4ml year_12.4ml... (3 Replies)
Discussion started by: kylle345
3 Replies

4. Shell Programming and Scripting

Getting rip of multiple rows based on column1

Hi, I want to get rid of multiple rows (duplicate, triplicate etc..) for only column 1. e.g. iu 2 iu 1 iu 3 k 4 jk 3 nm 4 nm 2 output k 4 jk 3 thanks (7 Replies)
Discussion started by: phil_heath
7 Replies

5. Shell Programming and Scripting

awk : Remove column1 and last column in a line

Hi All, How to remove col1 and last column in a line. Please suggest some awk stuffs. Input col1 col2 col3 col4 col1 col2 col3 col4 col5 col1 col2 col3 col4 col1 col2 col3 Output Processing col2 col3 ... Processing col2 col3 col4 ... Processing col2 col3 ... Processing... (5 Replies)
Discussion started by: k_manimuthu
5 Replies

6. Shell Programming and Scripting

How to change value in CSV columns and compare two files where Column1 is identical

Hi all, Could someone help me with the following issue: 1st I have an CSV file delimiter is ";" I I have a column 7 where I need to do some multiple mathem. operation, I need all values in this columns to be multiplied by 1.5 and create a new CSV file with the replaced values. 2nd. I... (3 Replies)
Discussion started by: kl1ngac1k
3 Replies

7. Shell Programming and Scripting

Replace text in column1 of a file matching columns of another file

Hi all, I have 2 files: species-names.txt Abaca-bunchy-top-virus ((((Abaca-bunchy-top-virus((Babuvirus((Unassigned((Nanoviridae((Unassigned)))) Abutilon-mosaic-virus ((((Abutilon-mosaic-virus((Begomovirus((Unassigned((Geminiviridae((Unassigned))))... (2 Replies)
Discussion started by: thienxho
2 Replies

8. Shell Programming and Scripting

Help with Perl script for identifying dupes in column1

Dear all, I have a large dictionary database which has the following structure source word=target word e.g. book=livre Since the database is very large in spite of all the care taken, it so happens that at times the source word is repeated e.g. book=livre book=tome Since I want to... (7 Replies)
Discussion started by: gimley
7 Replies

9. Programming

Perl script to merge cells in column1 which has same strings, for all sheets in a excel workbook

Perl script to merge cells ---------- Post updated at 12:59 AM ---------- Previous update was at 12:54 AM ---------- I am using below code to read files from a dir and print to excel. open(my $in, '<', $file) or die "Could not open file: $!"; my $rowCount = 0; my $colCount = 0;... (11 Replies)
Discussion started by: Jack_Bruce
11 Replies

10. Shell Programming and Scripting

CSV File:Filter duplicate records from column1 & another column having unique record

Hi Experts, I have csv file with 30, 40 columns Pasting just 2 column for problem description. Need to print error if below combination is not present in file check for column-1 (DocumentNumber) and filter columns where value in DocumentNumber field is same. For all such rows, the field... (7 Replies)
Discussion started by: as7951
7 Replies
NETGROUP_MKDB(8)					    BSD System Manager's Manual 					  NETGROUP_MKDB(8)

NAME
netgroup_mkdb -- generate the netgroup database SYNOPSIS
netgroup_mkdb [-o database] [file] DESCRIPTION
netgroup_mkdb creates a db(3) database for the specified file. If no file is specified, then /etc/netgroup is used. This database is installed into /var/db/netgroup.db. The file must be in the correct format (see netgroup(5)). The options are as follows: -o database Put the output databases in the named file. The databases are used by the C library netgroup routines (see getnetgrent(3)). netgroup_mkdb exits zero on success, non-zero on failure. FILES
/var/db/netgroup.db The current netgroup database /var/db/netgroup.db.tmp A temporary file /etc/netgroup The current netgroup file SEE ALSO
db(3), getnetgrent(3), netgroup(5) BUGS
Because netgroup_mkdb guarantees not to install a partial destination file it must build a temporary file in the same file system and if suc- cessful use rename(2) to install over the destination file. If netgroup_mkdb fails it will leave the previous version of the destination file intact. BSD
May 20, 2007 BSD
All times are GMT -4. The time now is 09:14 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy