Sponsored Content
Top Forums Shell Programming and Scripting How to search a filename stored in a variable using a pattern? Post 302836303 by Little on Wednesday 24th of July 2013 02:31:15 AM
Old 07-24-2013
How to search a filename stored in a variable using a pattern?

hi,

i have a variable which contains some file names delimited by a single space.
Code:
FNAME="s1.txt s2.lst s3.cvs s4.lst"

i have another variable that contains a pattern
Code:
FILE_PATTERN="*.lst"

i want to take the filenames from FNAME variable and assign each file name in to an array say
for example:- *.lst will match two files that are s2.lst and s4.lst, so i want to assign s2.lst and s4.lst to a array
Code:
FILE[0]="s2.lst"
FILE[1]="s4.lst"

can anyone say how can i do the above.?

Thanks
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

AWK: pattern not properly stored in variable?

Hey there, I have a table of contents file of the form 1 Title1 1.1 Subtitle1 1.1.1 Subsubtitle1 1.1.2 Subsubtitle2 ... and want to count the number of dots in the first field to find out the level of the section. I use the gsub function for the job, which works if I pass the pattern... (2 Replies)
Discussion started by: herrsimon
2 Replies

2. Shell Programming and Scripting

Search for awk pattern in unix env variable

For a Script I need to detemine which field of the unix environment variable SHLIB_PATH has the WALTDB entry. export SHLIB_PATH=/usr/user5/WALTDB/oracle/product/10.2.0/lib32:/usr/TZD/bin.wdad/mug/oracle/lib: echo $SHLIB_PATH | awk -F: '{ print $1 }' Shure gives me the first entry, but... (6 Replies)
Discussion started by: sdohn
6 Replies

3. Shell Programming and Scripting

How to assign the Pattern Search string as Input Variable

guys, I need to know how to assing pattern matched string as an input command variable. Here it goes' My script is something like this. ./routing.sh <Server> <enable|disable> ## This Script takes an input <Server> variable from this line of the script ## echo $1 | egrep... (1 Reply)
Discussion started by: raghunsi
1 Replies

4. Shell Programming and Scripting

search the pattern in a file and replace with variable already defined previously in csh

I want to replace a certain pattern with the variable already defined. e.g. set path_verilog = /home/priya/bin/verilogfile my file contents are : verilog new verilog is defined here verilog_path_comes I am using the below command sed 's/verilog_path_comes/'$path_verilog'/g' <filename>... (2 Replies)
Discussion started by: nehashine
2 Replies

5. Shell Programming and Scripting

PERL : pattern matching a string stored in a variable

I have two variables, my $filename = "abc_yyyy_mm_dd.txt"; my $filename1 = " abc_2011_11_07.txt"; I need to perform some operations after checking if $filename has $filename1 in it i have used the below code, if($filename =~ /^$filename1/) { ---- -- } (2 Replies)
Discussion started by: irudayaraj
2 Replies

6. Shell Programming and Scripting

[Solved] Replace extension of filename stored in a variable

Hi there, I have a small question (most like a true beginners question :) ). In a script I have a filename stored in variable (vFile). Through the an input parameter this variable gets its value (for instance cookie.txt). Two new variables are created with the value of vFile, but with a... (2 Replies)
Discussion started by: rberkers
2 Replies

7. UNIX for Dummies Questions & Answers

Assigning matched pattern within filename to variable

I am writing a bash script where I use two types of files that both contain a numerical pattern of the type 123.4567 (always groups of three and four digits separated by period) within their filenames. I need to assign the numerical patterns of these filenames to variables (inside a for loop),... (6 Replies)
Discussion started by: Mauve
6 Replies

8. Shell Programming and Scripting

Search if file exists for a file pattern stored in array

Hi experts, I have two arrays one has the file paths to be searched in , and the other has the files to be serached.For eg searchfile.dat will have abc303 xyz123 i have to search for files that could be abc303*.dat or for that matter any extension . abc303*.dat.gz The following code... (2 Replies)
Discussion started by: 100bees
2 Replies

9. Shell Programming and Scripting

awk variable search and line count between variable-search pattern

Input: |Running the Rsync|Sun Oct 16 22:48:01 BST 2016 |End of the Rsync|Sun Oct 16 22:49:54 BST 2016 |Running the Rsync|Sun Oct 16 22:54:01 BST 2016 |End of the Rsync|Sun Oct 16 22:55:45 BST 2016 |Running the Rsync|Sun Oct 16 23:00:02 BST 2016 |End of the Rsync|Sun Oct 16 23:01:44 BST 2016... (4 Replies)
Discussion started by: busyboy
4 Replies

10. Shell Programming and Scripting

awk -Search pattern through Variable

Hello, We have wrote shell script for multiple file name search pattern. file format: <numner>_<20180809>.txt starting with single number and ending with 8 digits number Command: awk -v string="12_1234" -v serch="^+_+$" "BEGIN{ if (string ~/serch$/) print string }" If sting matches... (4 Replies)
Discussion started by: koti_rama
4 Replies
KCPUSET(9)						   BSD Kernel Developer's Manual						KCPUSET(9)

NAME
kcpuset, kcpuset_create, kcpuset_destroy, kcpuset_copy, kcpuset_use, kcpuset_unuse, kcpuset_copyin, kcpuset_copyout, kcpuset_zero, kcpuset_fill, kcpuset_set, kcpuset_clear, kcpuset_isset, kcpuset_iszero, kcpuset_match, kcpuset_merge, kcpuset_atomic_set, kcpuset_atomic_clear -- dynamic kernel CPU sets SYNOPSIS
#include <sys/kcpuset.h> void kcpuset_create(kcpuset_t **retkcp, bool zero); void kcpuset_destroy(kcpuset_t *kcp); void kcpuset_copy(kcpuset_t *dkcp, kcpuset_t *skcp); void kcpuset_use(kcpuset_t *kcp); void kcpuset_unuse(kcpuset_t *kcp, kcpuset_t **lst); int kcpuset_copyin(const cpuset_t *ucp, kcpuset_t *kcp, size_t len); int kcpuset_copyout(kcpuset_t *kcp, cpuset_t *ucp, size_t len); void kcpuset_zero(kcpuset_t *kcp); void kcpuset_fill(kcpuset_t *kcp); void kcpuset_set(kcpuset_t *kcp, cpuid_t cpu); void kcpuset_clear(kcpuset_t *kcp, cpuid_t cpu); int kcpuset_isset(kcpuset_t * kcp, cpuid_t cpu); bool kcpuset_iszero(kcpuset_t *kcp); bool kcpuset_match(const kcpuset_t *kcp1, const kcpuset_t *kcp2); void kcpuset_merge(kcpuset_t *kcp1, kcpuset_t *kcp2); void kcpuset_atomic_set(kcpuset_t *kcp, cpuid_t cpu); void kcpuset_atomic_clear(kcpuset_t *kcp, cpuid_t cpu); DESCRIPTION
The machine-independent kcpuset subsystem provides support for dynamic processor sets. Conceptually kcpuset can be understood to be the ker- nel equivalent of the user space cpuset(3) interface. FUNCTIONS
kcpuset_create(retkcp, zero) The kcpuset_create() function creates a dynamic CPU set and stores the result to retkcp. If the boolean zero is not false, the allocated set is also initialized to zero. kcpuset_destroy(kcp) Destroys the CPU set kcp and schedules any linked CPU sets for deferred destruction. kcpuset_copy(dkcp, skcp) Copies the CPU set pointed by skcp to dkcp. kcpuset_use(kcp) Marks kcp as being in use by increasing the reference count of the object. Note that initially kcpuset_create() sets the reference count to 1. kcpuset_unuse(kcp, lst) Decreases the internal reference count of kcp, and on the last reference (when the count reaches zero), destroys kcp. If lst is not NULL, then instead of destroying, kcp will be added to the lst list for a deferred destruction. kcpuset_copyin(ucp, kcp, len) Copies the len bytes long user-space CPU set ucp to the kernel CPU set kcp. kcpuset_copyout(kcp, ucp, len) Copies the kernel CPU set kcp to the user-space CPU set ucp. kcpuset_zero(kcp) Clears the set kcp. kcpuset_fill(kcp) Fills the whole set kcp with ones. kcpuset_set(kcp, cpu) Adds cpu to the set kcp. kcpuset_clear(kcp, cpu) Removes cpu from the set kcp. kcpuset_isset(kcp, cpu) Returns 1 if cpu is part of the CPU set kcp. kcpuset_iszero(kcp) Returns true if the set kcp is empty. kcpuset_match(kcp1, kcp2) Compares the sets kcp1 and kcp2, returning true if these are identical. kcpuset_merge(kcp1, kcp2) Merges the set kcp2 to the set kcp1. kcpuset_atomic_set(kcp, cpu) The kcpuset_atomic_set() function operates as kcpuset_set(), but the operation is atomic; see atomic_ops(3) for more details. kcpuset_atomic_clear(kcp, cpu) Removes cpu from the CPU set kcp atomically. CODE REFERENCES
The kcpuset subsystem is implemented within sys/kern/subr_kcpuset.c. SEE ALSO
cpuset(3) HISTORY
The kcpuset subsystem first appeared in NetBSD 6.0. BSD
October 6, 2011 BSD
All times are GMT -4. The time now is 03:23 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy