Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Expand Variables and Wildcards into another variable. Post 303035140 by chetanojha on Wednesday 15th of May 2019 06:21:19 AM
Old 05-15-2019
Thanks Anbu23 for quick reply. The command sent by you is working.



But what is the difference between below two?

Code:
file_path=${output_dir} 

files_list=`ls ${output_dir}/*MIGRATE*${city_name}*.out`

and

Code:
file_path=${output_dir} 

files_list=`echo ${output_dir}/*MIGRATE*${city_name}*.out`

both seems to be working..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How can I put wildcards in an if statement that uses variables?

With the if statement: if How can I make it so it accepts a wildcard after the ${CURR_DAY_MONTH} variable? Putting a -f /webtrends/SUN/mrw2/access.${CURR_DAY_DAY}${CURR_DAY_MONTH}* won't work, right? I think I need some kind of special character so it knows the wildcard is... (3 Replies)
Discussion started by: LordJezo
3 Replies

2. Shell Programming and Scripting

how to seperate a variable in 2 variables

Dear all, i dont know how to split one variable value in 2 variable. please send me any example. variable1= "abcde developer" now i want to seperate the values and seperator is space. (6 Replies)
Discussion started by: intikhabalam
6 Replies

3. UNIX for Dummies Questions & Answers

how to expand environment variables in a file?

I am new to unix and would appreciate if someone could help. I have an environment variable SourceFilePath=/db1/Src/test set on the unix server. I want to expand this SHELL variable in a file using any command sed, awk etc File contents is as follows: var=$SourceFilePath/file.txt ... (2 Replies)
Discussion started by: debbie15
2 Replies

4. UNIX for Dummies Questions & Answers

Using wildcards in variables in zsh

Probably a stupid question... how do I use a wildcard in a variable in zsh? If I do: var=* echo $var in bash, it will print all files/directories in the current directory. If I do it in zsh, it will only output an asterisk without the wildcard functionality. Thanks in advance! (1 Reply)
Discussion started by: RainbowLAr
1 Replies

5. Shell Programming and Scripting

For loop using input file doesn't expand variables

Hi, I'm using a for loop reading from an input file that contains files, whose path includes a variable name. But the for loop doesn't expand the variable and therefore can't find the file. Here's an example: File BACKUPFILES /home/John/alpha /home/Sue/beta... (8 Replies)
Discussion started by: Hesiod
8 Replies

6. Shell Programming and Scripting

Expand an environment variable in sed, when the variable contains a slash

I'm trying to make a sed substitution where the substitution pattern is an environment variable to be expanded, but the variable contains a "slash". sed -e 's/<HOME_DIRECTORY>/'$HOME'/'This gives me the following error: sed: -e expression #1, char 21: unknown option to `s'Obviously this is... (2 Replies)
Discussion started by: Ilja
2 Replies

7. Shell Programming and Scripting

dynamic variables - eval - expand etc.

Hello, so i'm making a script, using dynamic variables and trying to expand them. So far it hasn't worked out too well so it seems that I need some help from you, the elite. Example: #!/bin/sh counter=0 until (($counter>5)) counter2=1 until (($counter2>6)); do if ;... (5 Replies)
Discussion started by: TehOne
5 Replies

8. Shell Programming and Scripting

How to set a variable name from another variables value?

Experts, I want to set value of variables like this in bash shell: i=5 ; L=100 I want variable d5 (that is d(i) ) to be assign the value of $L , d$i=$L ; echo $d5 Not working Thanks., (3 Replies)
Discussion started by: rveri
3 Replies

9. Shell Programming and Scripting

Variable variables

Hello, Can you please help here? DAY=$1 MONTH_MONDAY_YEAR = 1 2 3 4 for i in ${MONTH_${DAY}_YEAR} do echo ${i} done ./test.sh MONDAY ./test.sh: line 3: MONTH_MONDAY_YEAR: command not found ./test.sh: line 10: ${MONTH_${DAY}_YEAR}: bad substitution (6 Replies)
Discussion started by: vino_hymi
6 Replies

10. Shell Programming and Scripting

How to handle grepping variable data containing wildcards?

I have a lot of files with keywords and unique names. I'm using a shell script to refer to a simple pattern file with comma separated values in order to match on certain keywords. The problem is that I don't understand how to handle the wildcard values when I want to skip over the unique names. ... (5 Replies)
Discussion started by: abercrom
5 Replies
Explode(3pm)						User Contributed Perl Documentation					      Explode(3pm)

NAME
MIME::Explode - Perl extension for explode MIME messages SYNOPSIS
use MIME::Explode; my $explode = MIME::Explode->new( output_dir => "tmp", mkdir => 0755, decode_subject => 1, check_content_type => 1, content_types => ["image/gif", "image/jpeg", "image/bmp"], types_action => "exclude" ); print "Number of messages: ", $explode->nmsgs, " "; open(MAIL, "<file.mbox") or die("Couldn't open file.mbox for reading: $! "); open(OUTPUT, ">file.tmp") or die("Couldn't open file.tmp for writing: $! "); my $headers = $explode->parse(*MAIL, *OUTPUT); close(OUTPUT); close(MAIL); for my $part (sort{ $a cmp $b } keys(%{$headers})) { for my $k (keys(%{$headers->{$part}})) { if(ref($headers->{$part}->{$k}) eq "ARRAY") { for my $i (0 .. $#{$headers->{$part}->{$k}}) { print "$part => $k => $i => ", $headers->{$part}->{$k}->[$i], " "; } } elsif(ref($headers->{$part}->{$k}) eq "HASH") { for my $ks (keys(%{$headers->{$part}->{$k}})) { if(ref($headers->{$part}->{$k}->{$ks}) eq "ARRAY") { print "$part => $k => $ks => ", join(($ks eq "charset") ? " " : "", @{$headers->{$part}->{$k}->{$ks}}), " "; } else { print "$part => $k => $ks => ", $headers->{$part}->{$k}->{$ks}, " "; } print "$part => $k => $ks => ", $headers->{$part}->{$k}->{$ks}, " "; } } else { print "$part => $k => ", $headers->{$part}->{$k}, " "; } } } if(my $e = $explode->clean_all()) { print "Error: $e "; } DESCRIPTION
MIME::Explode is perl module for parsing and decoding single or multipart MIME messages, and outputting its decoded components to a given directory ie, this module is designed to allows users to extract the attached files out of a MIME encoded email messages or mailboxes. METHODS
new([, OPTION ...]) This method create a new MIME::Explode object. The following keys are available: output_dir Directory where the decoded files are placed mkdir => octal_number If the value is set to octal number then make the output_dir directory (example: mkdir => 0755). check_content_type => 0 or 1 If the value is set to 1 the content-type of file is checked decode_subject => 0 or 1 If the value is set to 1 then the subject is decoded into a list. $header->{'0.0'}->{subject}->{value} = [ARRAYREF]; $header->{'0.0'}->{subject}->{charset} = [ARRAYREF]; $subject = join("", @{$header->{'0.0'}->{subject}->{value}}); exclude_types => [ARRAYREF] Not save files with specified content types (deprecated in next versions) content_types => [ARRAYREF] Array reference with content types for "include" or "exclude" types_action => "include" or "exclude" If the action is a "include", all attached files with specified content types are saved but if the action is a "exclude", no files are saved except if its in the array of content types. If no array is specified, but the action is a "include", all attached files are saved, otherwise all files are removed if action is a "exclude". The default action is "include". parse(FILEHANDLE, FILEHANDLE) This method parse the stream and splits it into its component entities. This method return a hash reference with all parts. The FILEHANDLE should be a reference to a GLOB. The second argument is optional. nmsgs Returns the number of parsed messages. clean_all Cleans all files from the "output_dir" directory and then removes the directory. If an error happens returns it. AUTHOR
Henrique Dias <henrique.ribeiro.dias@gmail.com> CREDITS
Thanks to Rui Castro for the revision. SEE ALSO
MIME::Tools, perl(1). perl v5.14.2 2011-06-26 Explode(3pm)
All times are GMT -4. The time now is 02:18 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy