Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Expand Variables and Wildcards into another variable. Post 303035138 by chetanojha on Wednesday 15th of May 2019 05:43:23 AM
Old 05-15-2019
Expand Variables and Wildcards into another variable.

Dear Forum members,


I am having trouble getting the complete filename (and directory path) in a variable.



Output directory mentioned in the code have three files:

Code:
DISPLAY_CITY_DETAILS_15-05-2019-08-29-26_MIGRATE_london.out
DISPLAY_CITY_DETAILS_15-05-2019-08-29-26_MIGRATE_paris.out
DISPLAY_CITY_DETAILS_15-05-2019-08-29-26_MIGRATE_rome.out

******************************************************
Code is as shown below:
I am tryin to get get the full path of the above files (including directory path in variable file_path).

Code:

output_dir=$HOME'/country/city/'

while IFS= read -r city_name
do
    
 ## None of the below command  worked.    



     file_path=`${output_dir}/*MIGRATE*${city_name}*.out`
    # eval file_path=`${output_dir}/*MIGRATE*${city_name}*.out`
    # file_path=${eval echo `ls ${output_dir} | grep "MIGRATE"`}
    # eval file_path=`ls ${output_dir} | grep "MIGRATE"`
       
    echo $file_path
 
done < ${city_list}    

##  city_list is the list of cities for which I want to display details

Can anybody help with the command?

Thanks.
 

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
kerberosautoconfig(8)					    BSD System Manager's Manual 				     kerberosautoconfig(8)

NAME
kerberosautoconfig -- Kerberos -- Open Directory Single Sign On SYNOPSIS
kerberosautoconfig [-f directory_node] [-o output_dir] [-r realm_name -m master_kdc] [-u] [-k] [-v debug_level] DESCRIPTION
The kerberosautoconfig command creates / updates & removes the edu.mit.Kerberos file and the Kerberos:<REALM_NAME> config record in dslocal db from information stored in the Open Directory config record named KerberosClient. The existing edu.mit.Kerberos file is only replaced if the autogenerated header is present and the generation_id in the KerberosClient config record is greater than that within the file. The default location of the output file is /Library/Preferences/edu.mit.Kerberos. If the machine is standalone, this command will do nothing (unless the -u option is used). Definitions: directory_node An open directory node path specifier. Such as /LDAPv3/127.0.0.1 output_dir The directory in which kerberosautoconfig deposits the edu.mit.Kerberos file realm_name Name of the Kerberos realm that will be the default when creating a file from scratch master_kdc Host name of the master KDC for the default realm when creating a file from scratch debug_level Specifies the amount of debugging information printed to stdout, default is 1 Flags: -f Tells kerberosautoconfig to look in the specified open directory node for the KerberosClient config record. -o Specifies the directory in which kerberosautoconfig will write the new edu.mit.Kerberos file into -r kerberosautoconfig can create an edu.mit.Kerberos file from information passed on the command line. Use the -r and -m flags to spec- ify the default realm and master KDC for that realm. -m See above -k Adds the default Kerberos logging directives to the config file (useful when setting up a kdc) -u Forces an update of the file. Will overwrite an existing non-autogenerated edu.mit.Kerberos file. Use with caution. -v Specifies the amount of debugging information printed to stdout, default is 1 FILES
/Library/Preferences/edu.mit.Kerberos The main Kerberos config file (also known as krb5.conf on other systems) SEE ALSO
DirectoryService(1), Kerberos(1), kdcsetup(8), krb5.conf(5) BUGS
kerberosautoconfig looks for the KerberosClient config record in each of the open directory nodes on the search path. It merges the realm information from any KerberosClient config records it finds, but it only checks the generation_id from the first config record found. This means that the file does not get updated if the second KerberosClient record found changes. HISTORY
kerberosautoconfig first appeared in Mac OS X 10.3 Darwin June 2, 2019 Darwin
All times are GMT -4. The time now is 06:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy