Pick up files to process using ls command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Pick up files to process using ls command
# 1  
Old 10-14-2015
Pick up files to process using ls command

Hello All,

I have a list of files as below
---------
Code:
FORM_PTIR_9484_ANFDOP_20150716_00263059.DAT
FORM_PTIR_9484_TIFDOP_20150716_00263059.DAT
FORM_PTIR_9484_EXFDOP_20150716_00263059.DAT
FORM_PTIR_9484_ANFDEX_20150716_00263059.DAT
FORM_PTIR_9484_ANFDCA_20150716_00263059.DAT

and so on....
----------

My previous requirement was for files to be picked up were AN??OP
So i used the wildcard like ????_????_????_AN??OP_*


But now, I have to pick files where the middle thing AN?? remains but last part <>EX
so, in short I can pick up files AN??OP and AN??CA but not AN
??EX

Can you please help ?

Moderator's Comments:
Mod Comment edit by bakunin: in fact i can and did help - i placed CODE- and ICODE-tags where they belonged to. In turn i just ask you to do that yourself from now on. Thank you.

Last edited by bakunin; 10-14-2015 at 11:07 AM..
# 2  
Old 10-14-2015
Try
Code:
ls *AN??[^E][^X]* *AN??E[^X]* *AN??[^E]X*

This User Gave Thanks to RudiC For This Post:
# 3  
Old 10-14-2015
Hello Friends,

I appreciate your help But lets say, I have the given set of files (listed above)
if these 3 positions are considered as aa, bb, cc then
say aa=AN
bb= any
cc <> EX

I have to consider only those files which have aa=AN, bb= any and CC <> EX.

This was first requirement

Now second requirement would be where I need to list out all those files which do not satisfy the criteria ....I have to move them to other folder. So, can you help me ?
Moderator's Comments:
Mod Comment edit by bakunin: doubled post removed

Last edited by bakunin; 10-14-2015 at 11:20 AM..
# 4  
Old 10-14-2015
Why don't you move the files found to a temp directory, move the rest to your other folder, and move back from the temp?
# 5  
Old 10-14-2015
Moderator's Comments:
Mod Comment Dear rac,

PLEASE: use CODE-tags to let code(-parts) and file content stand out from your text. It helps others to understand your problem better.

Furthermore, whatever your problem is, always provide three things:

1. an accurate problem description (this you did)

2. an accurate description of your system. "UNIX" is an OS with many, many flavours and running on a lot of (quite disparate) hardware. Your system might be quite different from mine in obvious or rather subtle ways. To help you better it helps to know your system because the one special quirk my system doesn't have yours might.

3. a description of what you have tried already and how it failed
it simply helps to find out what went wrong when one sees an error message like "file not found" or "disk full" or whatever. You may not have noticed it or not understood its importance (there are less obvious messages as my examples) but others may understand and others may notice.

Please keep that in mind and we will get along much better than now.


bakunin
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Pick file and Trigger informatica process

Hi, I am creating a script in which we will check a folder. If any file placed inside the folder, script will move the file to another folder and Trigger etl process. Now the issue is that the script should continously check the presence of file inside folder after every minute or hour. So how... (1 Reply)
Discussion started by: dgargd2524
1 Replies

2. Shell Programming and Scripting

Code to pick all files from a directory and send it to a command

(4 Replies)
Discussion started by: rossi
4 Replies

3. UNIX for Advanced & Expert Users

How to pick only current week files?

Hi, My job will run every friday and it should pick only that week files. For Ex: this 24th May job will trigger and it should pick 20,21,22,23,24.and 19th sun and 18th sat we dont have files to pick. currently i am using the below code and it is working fine, but sometimes it is picking... (3 Replies)
Discussion started by: kiranparsha
3 Replies

4. Shell Programming and Scripting

How to pick only the files which are generated in one hour?

Hello Masters, I need one help. I want to copy the files which are continuously generating on one server. But this would be on hourly basis. e.g. -rw-rw-r-- 1 akore akore 0 Feb 12 03:20 test1.log -rw-rw-r-- 1 akore akore 0 Feb 12 03:42 test2.log -rw-rw-r-- 1 akore akore 0 Feb 12 04:22... (2 Replies)
Discussion started by: akore83
2 Replies

5. UNIX for Dummies Questions & Answers

Need command to pick the latest file

Hi In my script i am trying to access mainframe server using FTP, in the server i have filee with the timestamp.I need to get the file with the latest timestamp among them . The server has the below files / ftp> cd /outbox 250 CWD command successful ftp> ls 200 PORT command successful... (4 Replies)
Discussion started by: laxmi131
4 Replies

6. Shell Programming and Scripting

Pick random file from ls command.

Lets say I want to pick a random file when I do an "ls" command. I don't have set number of files in each directory. ls | head -1 This gives me the first one in each directory, is there a way to do the same but pick a random one. (3 Replies)
Discussion started by: elbombillo
3 Replies

7. Shell Programming and Scripting

need to pick out files which are not of zero bytes

I need a scriptto print only those files from a list of files starting with STMT* which are not of zero bytes ...i.e they have some size if these are the files 631 -rw-r--r-- 1 assrisa assrisa 39099 Aug 19 07:16 STMT_05_D1090819_T071320 -rw-r--r-- 1 assrisa assrisa 0 Aug 19... (2 Replies)
Discussion started by: viv1
2 Replies

8. Shell Programming and Scripting

Pick the latest set of files

I have task in which I need to pickup a set of files from a directory depending on the following criteria: Every month 6 files are expected to arrive at /test. The files come with date timestamp and the latest file set for the month needs to be used Suppose this is the set of files that present... (5 Replies)
Discussion started by: w020637
5 Replies

9. Shell Programming and Scripting

How does mutt command pick senders Details

Hi All, We use mutt in one of our scripts to send files as a part of a batch job . The command works nicely but i want to know from where does mutt pick the sender details. As the sender id is different if i use mutt and Mail utility. I can not change the command to mail as it is a part of the... (1 Reply)
Discussion started by: amit1_x
1 Replies
Login or Register to Ask a Question