Sponsored Content
Top Forums Shell Programming and Scripting Comparing two strings receiving form two different loops and execute if condition when single match Post 302874077 by ketanraut on Thursday 14th of November 2013 04:08:31 AM
Old 11-14-2013
Linux Comparing two strings receiving form two different loops and execute if condition when single match

I want to read a file contain sub-string and same string need to match in file name I got from for loop. I am using below code:
Code:
#!/bin/bash
C_UPLOADEDSUFFIX='.uploaded'
files=$(find . -iname '*'$C_UPLOADEDSUFFIX -type f)  # find files having .uploaded prefix
for file in $files
do
 CHK_FILE=$(basename $file)
     while read -r line; do
                  set -f          # disable globbing
 
          if [[ $CHK_FILE =~ "${line}*" ]]
 
          then
 
                  uploader()
          else
                  trap()
          fi
 
  done < FILE_NAME.txt
done

in this code if match found in if statement then uploader() run else trap() run, so it always goes to else part unnecessarily each time if condition fails.
I want, if condition " [[ $CHK_FILE =~ "${line}*" ]]” first check for all strings in FILE_NAME.txt one by one and if at least single match found then it must execute uploader() else execute trap().

Code:
FILE_NAME.txt---->
Blacklist
Customer
languages
Nationality


Last edited by vbe; 11-14-2013 at 05:23 AM.. Reason: more tags + rm fancy fonts
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

comparing two strings

Hi How do i compare two strings in shell script. Below is an example but I am not getting the desired output, plz help if then echo success fi I am not getting the desired output if I do this. plz help (24 Replies)
Discussion started by: ragha81
24 Replies

2. UNIX for Advanced & Expert Users

Comparing strings

I have two strings a=Mar22 b=may21 how can I compare them Is this fine if then; . ... else .... fi or if then (2 Replies)
Discussion started by: yakyaj
2 Replies

3. Shell Programming and Scripting

Comparing Two Strings

Hi All, While I am trying to run below code I Am getting the exception like ./abs.sh: line 102: syntax error near unexpected token `then' ./abs.sh: line 102: ` then' The Code Snippet is: if then cat $file1 | sed -e... (8 Replies)
Discussion started by: Anji
8 Replies

4. Shell Programming and Scripting

comparing 2 strings

hi i have 2 strings. i want to compare the strings. please help (2 Replies)
Discussion started by: satish@123
2 Replies

5. Shell Programming and Scripting

form a line with strings

hi i have a file with the content like TL1330000000800 000DE9147157200 08000TS0228DE91 71572AMEX0000.T N 0080000000 00000. TL1330000000500 000DE9147157200 08000TS0228DE91 71572AMEX0000.T N 0080000000 00000. i need to write like including the spaces ... (4 Replies)
Discussion started by: Satyak
4 Replies

6. Shell Programming and Scripting

Net::SSH::Perl->Execute any unix command & display the output in a proper form

Net::SSH::Perl ...... how to print the output in a proper format my $cmd = "ls -l"; my $ssh = Net::SSH::Perl->new($host); $ssh->login($user, $pass); my($stdout, $stderr, $exit) = $ssh->cmd("$cmd"); print $stdout; the script works fine, but i am unable to see the output... (2 Replies)
Discussion started by: gsprasanna
2 Replies

7. UNIX for Advanced & Expert Users

need to get single column form csv file

hi 2 all i need to get single column from one csv file anyone help me ! >cat file.csv name,age x,1 y,2 z,3 Use code tags please, ty. in this "file.csv" file i need only name column can u help me !:b::b: (7 Replies)
Discussion started by: ponmuthu
7 Replies

8. Programming

C++ for loops in a single line

I am wondering whether I can write for loops in the following ways for (int i = 0; i < NL; i++) L->read_param(P, i + 1); for (int k = 0; k < lay; k++) sum += L->get_npar(); for (int i = 0; i < NL; i++) L = new Layer(Xi, Xf); for (int i = 0; i < NL; i++) { for (int j = 0; j < NL; j++)... (3 Replies)
Discussion started by: kristinu
3 Replies

9. Shell Programming and Scripting

Match child with parents and form matrix

thank you for letting me join this forum, lots of learning opportunities looks like. Myself a biologist, very new into unix, so please excuse if I use incorrect language. I am using cygwin on windows, it can run perl, awk , sed etc. I have 2 files, the first sample sheet, tells which parent... (10 Replies)
Discussion started by: jalaj841
10 Replies

10. UNIX for Beginners Questions & Answers

Use strings from nth field from one file to match strings in entire line in another file, awk

I cannot seem to get what should be a simple awk one-liner to work correctly and cannot figure out why. I would like to use patterns from a specific field in one file as regex to search for matching strings in the entire line ($0) of another file. I would like to output the lines of File2 which... (1 Reply)
Discussion started by: jvoot
1 Replies
DEBRELEASE(1)						      General Commands Manual						     DEBRELEASE(1)

NAME
debrelease - a wrapper around dupload or dput SYNOPSIS
debrelease [debrelease options] [dupload/dput options] DESCRIPTION
debrelease is a simple wrapper around dupload or dput. It is called from within the source code tree of a package, and figures out the current version of a package. It then looks for the corresponding .changes file (which lists the files needed to upload in order to release the package) in the parent directory of the source code tree and calls dupload or dput with the .changes file as parameter in order to perform the actual uploading. Options may be given to debrelease; except for the ones listed below, they are passed on unchanged to dupload or dput. The devscripts con- figuration files are also read by debrelease as described below. Directory name checking In common with several other scripts in the devscripts package, debrelease will climb the directory tree until it finds a debian/changelog file. As a safeguard against stray files causing potential problems, it will examine the name of the parent directory once it finds the debian/changelog file, and check that the directory name corresponds to the package name. Precisely how it does this is controlled by two configuration file variables DEVSCRIPTS_CHECK_DIRNAME_LEVEL and DEVSCRIPTS_CHECK_DIRNAME_REGEX, and their corresponding command-line options --check-dirname-level and --check-dirname-regex. DEVSCRIPTS_CHECK_DIRNAME_LEVEL can take the following values: 0 Never check the directory name. 1 Only check the directory name if we have had to change directory in our search for debian/changelog. This is the default behaviour. 2 Always check the directory name. The directory name is checked by testing whether the current directory name (as determined by pwd(1)) matches the regex given by the con- figuration file option DEVSCRIPTS_CHECK_DIRNAME_REGEX or by the command line option --check-dirname-regex regex. Here regex is a Perl regex (see perlre(3perl)), which will be anchored at the beginning and the end. If regex contains a '/', then it must match the full directory path. If not, then it must match the full directory name. If regex contains the string 'PACKAGE', this will be replaced by the source package name, as determined from the changelog. The default value for the regex is: 'PACKAGE(-.+)?', thus matching directory names such as PACKAGE and PACKAGE-version. OPTIONS
--dupload, --dput This specifies which uploader program to use; the default is dupload. -S If this option is used, or the default .changes file is not found but a source-only .changes file is present, then this source-only .changes file will be uploaded instead of an arch-specific one. -adebian-architecture, -tGNU-system-type See dpkg-architecture(1) for a description of these options. They affect the search for the .changes file. They are provided to mimic the behaviour of dpkg-buildpackage when determining the name of the .changes file. If a plain -t is given, it is taken to be the dupload host-specifying option, and therefore signifies the end of the debrelease-specific options. --multi Multiarch changes mode: This signifies that debrelease should use the most recent file with the name pattern package_ver- sion_*+*.changes as the changes file, allowing for the changes files produced by dpkg-cross. --debs-dir directory Look for the .changes and .deb files in directory instead of the parent of the source directory. This should either be an absolute path or relative to the top of the source directory. --check-dirname-level N See the above section Directory name checking for an explanation of this option. --check-dirname-regex regex See the above section Directory name checking for an explanation of this option. --no-conf, --noconf Do not read any configuration files. This can only be used as the first option given on the command-line. --help, -h Display a help message and exit successfully. --version Display version and copyright information and exit successfully. CONFIGURATION VARIABLES
The two configuration files /etc/devscripts.conf and ~/.devscripts are sourced in that order to set configuration variables. Command line options can be used to override configuration file settings. Environment variable settings are ignored for this purpose. The currently recognised variables are: DEBRELEASE_UPLOADER The currently recognised values are dupload and dput, and it specifies which uploader program should be used. It corresponds to the --dupload and --dput command line options. DEBRELEASE_DEBS_DIR This specifies the directory in which to look for the .changes and .deb files, and is either an absolute path or relative to the top of the source tree. This corresponds to the --debs-dir command line option. This directive could be used, for example, if you always use pbuilder or svn-buildpackage to build your packages. Note that it also affects debc(1) and debi(1). DEVSCRIPTS_CHECK_DIRNAME_LEVEL, DEVSCRIPTS_CHECK_DIRNAME_REGEX See the above section Directory name checking for an explanation of these variables. Note that these are package-wide configuration variables, and will therefore affect all devscripts scripts which check their value, as described in their respective manpages and in devscripts.conf(5). SEE ALSO
dupload(1), dput(1) and devscripts.conf(5). AUTHOR
Julian Gilbey <jdg@debian.org>, based on the original release script by Christoph Lameter <clameter@debian.org>. DEBIAN
Debian Utilities DEBRELEASE(1)
All times are GMT -4. The time now is 08:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy