Issue with wildcard in filename (AIX 7.1.0.0)


 
Thread Tools Search this Thread
Operating Systems AIX Issue with wildcard in filename (AIX 7.1.0.0)
# 1  
Old 01-06-2018
Issue with wildcard in filename (AIX 7.1.0.0)

Hi,

This has been pestering me for quite a while, any help will be highly appreciated

The current directory has a file with below name

Code:
npidata_20050523-20171210.csv

The below wildcard matched the above file

Code:
ls -ltr npidata_????????-201712??.csv

But when the part '201712' is put into a variable and use in the file name somehow does not match the file name

Code:
ls -ltr npidata_?????????${yyyymm}??.csv

Is there a way I can get around this ?
# 2  
Old 01-06-2018
I cannot reproduce this:
Code:
$ touch npidata_20050523-20171210.csv
$ ls -ltr npidata_????????-201712??.csv
-rw-r--r--  1 scrutinizer  staff  0 Jan  6 20:49 npidata_20050523-20171210.csv
$ yyyymm=201712
$ ls -ltr npidata_?????????${yyyymm}??.csv
-rw-r--r--  1 scrutinizer  staff  0 Jan  6 20:49 npidata_20050523-20171210.csv

I did notice you used a ? instead of a -, but since a ? matches a - that is still a match.
Code:
$ ls -ltr npidata_????????-${yyyymm}??.csv
-rw-r--r--  1 scrutinizer  staff  0 Jan  6 20:49 npidata_20050523-20171210.csv

What shell are you using?

Last edited by Scrutinizer; 01-06-2018 at 03:59 PM..
# 3  
Old 01-06-2018
In addition to what Scrutinizer already asked...

What command (exactly) did you use to set the the variable yyyymm?
# 4  
Old 01-06-2018
I am using ksh and for the variable, I hard coded the value
Code:
yyyymm=20171210

# 5  
Old 01-06-2018
Quote:
Originally Posted by zulfi123786
I am using ksh and for the variable, I hard coded the value
Code:
yyyymm=20171210

That would be appropriate if the variable had been named yyyymmdd and you had used the filename matching pattern:
Code:
ls -ltr npidata_?????????${yyyymmdd}.csv

instead of:
Code:
ls -ltr npidata_?????????${yyyymm}??.csv

For the filename matching pattern you're using, you needed to set yyyymm using:
Code:
yyyymm=201712

instead of:
Code:
yyyymm=20171210

# 6  
Old 01-07-2018
well the actual reason of doing it this way was because I do not know the day part of the date which is why the pattern matching Smilie
# 7  
Old 01-07-2018
OK, but there is a mismatch this way so you would need to adapt the date. You could for example cut off the last two digits:
Code:
$ yyyymmdd=20171210
$ ls -ltr npidata_?????????${yyyymmdd%??}??.csv
-rw-r--r--  1 scrutinizer  staff  0 Jan  6 20:49 npidata_20050523-20171210.csv
$


Last edited by Scrutinizer; 01-08-2018 at 11:49 AM..
This User Gave Thanks to Scrutinizer For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

List filename of files only inside a directory (non-recurrsive) on AIX

I wish to list only files along with the absolute path in a given directory on my AiX 6.1 system. Below is the best I could do. ls -p "/app/scripts"/* This gives a a list of all filename along with folder names with absolute path non-recurrsive (without listing files in sub-directories)... (1 Reply)
Discussion started by: mohtashims
1 Replies

2. Shell Programming and Scripting

Issue when printing filename through cygwin using a variable with awk

Hi, If i were to do this an print out the file, it will show as it is in the command $ awk '/Privilege Use/ {P=0} /Object Access/ {P=1} P' AdvancedAudit.txt Object Access File System No Auditing Registry No Auditing Kernel... (1 Reply)
Discussion started by: alvinoo
1 Replies

3. UNIX for Dummies Questions & Answers

Is "stat: illegal option -- -" an issue with hyphenated filename or flag problem?

Hi. I'm trying to install VMWare Workstation to run a virtual machine on my Mac OS, but running the bundle from bash(xterm) sh VMware-workstation-Full-11.0.0-2305329.x86_64.bundle (as suggested in install guide) comes up with error:stat: illegal option -- - usage: stat Digging... (5 Replies)
Discussion started by: defeated
5 Replies

4. 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

5. AIX

GIT issue in AIX 6.1

Hello, I recently installed GIT 1.8.1 on my AIX 6.1 machine referring to AIX Open Source Packages | Main / git website and am facing a few issues with it. Now if I login as root and issue git commands like git --version I get the response as shown : git version 1.8.1And I have tried creating... (4 Replies)
Discussion started by: gaugeta
4 Replies

6. UNIX for Dummies Questions & Answers

grep pipe filename print issue

uname -a SunOS mypc 5.10 Generic_141414-07 sun4v sparc SUNW,SPARC-Enterprise-T2000 uname -a SunOS mypc 5.10 Generic_144488-07 sun4v sparc SUNW,SPARC-Enterprise-T5220 find . -name "*.cer" -exec keytool -v -list -printcert -file {} \; | grep -i "Aug 03" Valid from: Mon Jan 29 00:00:00 GMT... (16 Replies)
Discussion started by: shifahim
16 Replies

7. AIX

Issue "Error 404" when upgrade AIX 5300-05-CSP-0000 to AIX (5300-09-02-0849)

Please read my issue! My old server using: - AIX system operating (5300-05-CSP-0000) - WebSphere 6.1.0.21 (Fix Pack 21) After I've upgraded version AIX - AIX system operating (5300-09-02-0849) - WebSphere 6.1.0.21 (Fix Pack 21) I have 1 issue when I access home page: "Error... (0 Replies)
Discussion started by: gamonhon
0 Replies

8. AIX

Performance issue in AIX 5.3

Is there is any way to increase the CPU utilization of a Embedded SQL program in AIX 5.3 .. for performance purpose. (0 Replies)
Discussion started by: Gyanendra Awast
0 Replies

9. AIX

AIX Routing Issue

Hello, I've moved to a new network with multiple AIX box's. Most of them are working fine and dandy. On one box I need to set up a static route to a gateway.. no problem right? Whenever I add the route it appears in the routing table as UGc and then begins adding new entries to the... (1 Reply)
Discussion started by: joshstar14
1 Replies

10. 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
Login or Register to Ask a Question