Sponsored Content
Full Discussion: Wildcard search in if loop
Top Forums Shell Programming and Scripting Wildcard search in if loop Post 302866183 by kumaar1986 on Monday 21st of October 2013 12:41:48 PM
Old 10-21-2013
Code:
testval="${file%${file##???}}"

this code splits the first three letters in the file name. How to split the last 3 letters in the code. Im trying to modify the code so i can use the file extension
Code:
if[$testval= ".txt"]
do
echo some operation
done
else if [$testval=".xml"]
do
echo some operation
done

can u help me to achieve this operation.
The % and # markers are then followed by descriptions of how to split the line.
Is there any document to learn about how to do this. your help is appreciated
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Find wildcard .shtml files in wildcard directories and removing them- How's it done?

I'm trying to figure out how to build a small shell script that will find old .shtml files in every /tgp/ directory on the server and delete them if they are older than 10 days... The structure of the paths are like this: /home/domains/www.domain2.com/tgp/ /home/domains/www.domain3.com/tgp/... (1 Reply)
Discussion started by: Neko
1 Replies

2. Shell Programming and Scripting

use loop to search

Hi, I need to search through a file to find the last one occurence of my data. File1 is like this: sososo abc123 ssssss abc456 ssssss abc345 I need to loop through to identify the last occurence of "abc". So "abc345" is the record that I need. Can someone give me some ideas? (9 Replies)
Discussion started by: whatisthis
9 Replies

3. UNIX for Dummies Questions & Answers

how to search and list file with wildcard character

hi, I want to search all files in the current working direcotry and to print in comma (,) seperated output. But I have two patterns to search for. Files will be in ABC20100508.DAT format. Search should happen on the format (ABC????????.DAT) along with date(20100508). I can do a ls... (2 Replies)
Discussion started by: anandapani
2 Replies

4. Shell Programming and Scripting

ksh(!93) for loop with wildcard and empty directory

I'm sure this is by design, but using something like for f in dir/* do echo $f done produces unexpected (to me) results if run against an empty directory. I'd have expected it to not execute the loop, but it actually calls it with f set to 'dir/*'. Now I know that I'm trying to protect... (2 Replies)
Discussion started by: spr00t
2 Replies

5. Shell Programming and Scripting

Grep Wildcard search

How can i grep for a pattern with wildcard using grep? I want to identify all the lines that start with SAM and end in .PIPE IN.TXT SAM_HEADER.PIPE SAM_DETAIL.PIPE SAM_INVOICE.PIPE Can i do something like grep SAM*.PIPE IN.TXT (2 Replies)
Discussion started by: venky338
2 Replies

6. Shell Programming and Scripting

Speeding up search and replace in a for loop

Hello, I am using sed in a for loop to replace text in a 100MB file. I have about 55,000 entries to convert in a csv file with two entries per line. The following script works to search file.txt for the first field from conversion.csv and then replace it with the second field. While it works fine,... (15 Replies)
Discussion started by: pbluescript
15 Replies

7. Shell Programming and Scripting

Search a wildcard text in a file

Hi, I have a file(report.txt) that contains : 0 1 chk_uncov_data_assert 776 chk_uncov_data_assert : assert property (chk_uncov_data) 1 0 chk_data_assert 772 chk_data_assert : assert property (chk_data) 1 0 chk_data_cover ... (8 Replies)
Discussion started by: Anamika08
8 Replies

8. Emergency UNIX and Linux Support

Waiting for wildcard filename to exists in while loop

Hi Experts, We are developing a script which will wait for the trigger file(with datetime in the trigger file name). But the problem is when I use 'while' loop to wait for the file, it waits for the filename with wilcard in it that is wait for 'Trigger*.done' file. :eek: Below is the script ... (4 Replies)
Discussion started by: Amey Joshi
4 Replies

9. Shell Programming and Scripting

Grep and BzGrep with Wildcard in Search Pattern

Hello All, I hope this is the right area. If not, Kindly let me know and I will report in the appropriate spot. I am needing to find a search pattern that will make the * act as Wildcard in the search pattern instead of being literal. The example I am using is bzgrep "to=<*@domain.com>"... (5 Replies)
Discussion started by: mancountry
5 Replies

10. UNIX for Dummies Questions & Answers

Loop with Perl (string search)

I am using a perl script to reverse and complement sequences if a string is found. The script works as expected as standalone but I would like to use it in my bash file. However, I am not getting my expected result. My test.txt file >Sample_72... (8 Replies)
Discussion started by: Xterra
8 Replies
Locale::Codes::LangFam(3pm)				 Perl Programmers Reference Guide			       Locale::Codes::LangFam(3pm)

NAME
Locale::Codes::LangFam - standard codes for language extension identification SYNOPSIS
use Locale::Codes::LangFam; $lext = code2langfam('apa'); # $lext gets 'Apache languages' $code = langfam2code('Apache languages'); # $code gets 'apa' @codes = all_langfam_codes(); @names = all_langfam_names(); DESCRIPTION
The "Locale::Codes::LangFam" module provides access to standard codes used for identifying language families, such as those as defined in ISO 639-5. Most of the routines take an optional additional argument which specifies the code set to use. If not specified, the default ISO 639-5 language family codes will be used. SUPPORTED CODE SETS
There are several different code sets you can use for identifying language families. A code set may be specified using either a name, or a constant that is automatically exported by this module. For example, the two are equivalent: $lext = code2langfam('apa','alpha'); $lext = code2langfam('apa',LOCALE_LANGFAM_ALPHA); The codesets currently supported are: alpha This is the set of three-letter (lowercase) codes from ISO 639-5 such as 'apa' for Apache languages. This is the default code set. ROUTINES
code2langfam ( CODE [,CODESET] ) langfam2code ( NAME [,CODESET] ) langfam_code2code ( CODE ,CODESET ,CODESET2 ) all_langfam_codes ( [CODESET] ) all_langfam_names ( [CODESET] ) Locale::Codes::LangFam::rename_langfam ( CODE ,NEW_NAME [,CODESET] ) Locale::Codes::LangFam::add_langfam ( CODE ,NAME [,CODESET] ) Locale::Codes::LangFam::delete_langfam ( CODE [,CODESET] ) Locale::Codes::LangFam::add_langfam_alias ( NAME ,NEW_NAME ) Locale::Codes::LangFam::delete_langfam_alias ( NAME ) Locale::Codes::LangFam::rename_langfam_code ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangFam::add_langfam_code_alias ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangFam::delete_langfam_code_alias ( CODE [,CODESET] ) These routines are all documented in the Locale::Codes::API man page. SEE ALSO
Locale::Codes The Locale-Codes distribution. Locale::Codes::API The list of functions supported by this module. http://www.loc.gov/standards/iso639-5/id.php ISO 639-5 . AUTHOR
See Locale::Codes for full author history. Currently maintained by Sullivan Beck (sbeck@cpan.org). COPYRIGHT
Copyright (c) 2011-2013 Sullivan Beck This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.18.2 2013-11-04 Locale::Codes::LangFam(3pm)
All times are GMT -4. The time now is 01:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy