How to list files with specific condition?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to list files with specific condition?
# 1  
Old 05-02-2016
How to list files with specific condition?

Hi All,

Seeking for your assistance on how to list all files with letter h15 above on files.

Code:
ex.
ab0320443h14.zip
ab0320443b13.zip
ar0330016b15.zip
ar0330016h15.zip
ar0330267a16.zip
ar0330263c16.zip

output:
ar0330016h15.zip
ar0330267a16.zip
ar0330263c16.zip

Please advise,

Thanks,
# 2  
Old 05-02-2016
Would any two digit number, e.g. ar0330263c21.zip, satisfy the target condition as well?
# 3  
Old 05-02-2016
Is this a homework assignment? Homework and coursework questions can only be posted in the Homework & Coursework forum under special homework rules.

If this is not homework, please explain why you need an unlimited list of files that sort alhahumerically higher than another file's name.
# 4  
Old 05-02-2016
No Sir Don. because i want to put it in the loop statement. i don't know how to list it. all i can list is all the h15.
Code:
ls *h15*.zip

i tried also
ls *h>15*.zip ---ambigous redirect

but my code is wrong. T_T

Please advise,

Thanks,
# 5  
Old 05-02-2016
How come a16 is "above" h15? Lexicographically it would sort below.
# 6  
Old 05-03-2016
Quote:
Originally Posted by znesotomayor
Hi All,

Seeking for your assistance on how to list all files with letter h15 above on files.

Code:
ex.
ab0320443h14.zip
ab0320443b13.zip
ar0330016b15.zip
ar0330016h15.zip
ar0330267a16.zip
ar0330263c16.zip

output:
ar0330016h15.zip
ar0330267a16.zip
ar0330263c16.zip

Please advise,

Thanks,
Would any of these work?:

Code:
ls | perl -ne '$p=1 if /h15.zip$/; print if $p'
ar0330016h15.zip
ar0330263c16.zip
ar0330267a16.zip

Code:
ls | perl -ne 'print if $_ ge "ar0330016h15.zip"'
ar0330016h15.zip
ar0330263c16.zip
ar0330267a16.zip

This User Gave Thanks to Aia For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

A way to list directories that contain specific files.

Hi everyone My issue is this, I need to list all the sub directories in a directory that contains files that have the extension *.log, *.dat and *.out . After reviewing the output i need to delete those directories i do not need. I am running Solaris 10 in a bash shell. I have a script that I... (2 Replies)
Discussion started by: jsabo40
2 Replies

2. Shell Programming and Scripting

I have this list of files . Now I will have to pick the latest file based on some condition

3679 Jul 21 23:59 belk_rpo_error_**po9324892**_07212014.log 0 Jul 22 23:59 belk_rpo_error_**po9324892**_07222014.log 3679 Jul 23 23:59 belk_rpo_error_**po9324892**_07232014.log 22 Jul 22 06:30 belk_rpo_error_**po9324267**_07012014.log 0 Jul 20 05:50... (5 Replies)
Discussion started by: LoneRanger
5 Replies

3. Shell Programming and Scripting

Zip a list of specific files to an archive

Hi all, i've got the following problem: We've got a shell-script, that creates some different files based on several criteria given, using a sql-script. After creating, those files are individually zipped and stored, then sent to a ftp-server. This is all working since 2010, but now they have... (3 Replies)
Discussion started by: Biggreuda
3 Replies

4. UNIX for Dummies Questions & Answers

List of Files which are Greater then a specific date

A newbie question... I need to get a list of the Files and folders which are greater then a specific date. I want write the output to a Text file. What I know ls -lrt gives me list of all the files ordered by date. Also ls > fileName will write the results to a text file. Please help (6 Replies)
Discussion started by: rkaif
6 Replies

5. Shell Programming and Scripting

list files with a specific pattern

How can I list files with the following specific criteria? I am trying this $> ls *.log or $>ls *.log? --> but it only gives me fsaffa.log1, rwerw.log2. How can I get all three files with a simple selection criteria ? (5 Replies)
Discussion started by: kchinnam
5 Replies

6. Shell Programming and Scripting

List files with a certain condition

Guys help me out here.... I have the following var: date_system=20080507 And I have a folder with many files with the following pattern: test_%date%_reference, like test_20080201_tokyo.csv test_20080306_ny.csv and so on... What I need is: 1) list all files and them compare the... (1 Reply)
Discussion started by: Rafael.Buria
1 Replies

7. Filesystems, Disks and Memory

How to list files with specific created date

Hi, Would like to ask, which command is used to list all the files for specific date (says 1st May) and its size, for all files (including its subdirectory), in a mounted NFS disk to HP-UX. I would like to check for the total files came into my disk on 1st May. Very much appreciating your... (2 Replies)
Discussion started by: Draculla
2 Replies

8. Solaris

List all files that contain a specific directory

I need to list all files and subdirectories that contain "oradata". For example, I have several files in several different directories that contain "oradata". I.e. /u07/oradata/1.dbf /u09/unix/whatever/oradata/2.xxx That is, whatever file on the system that contains a directory called... (7 Replies)
Discussion started by: Sat510
7 Replies

9. Solaris

List files with a specific date...

Hi all, thanks in advance for reading and anyposts... I was wondering if its possible to find all files in a directory with a specific date. I know I can do: but that will only give a list of files greater than todays date... Any ideas? Thanks, Marky Mark... (4 Replies)
Discussion started by: B14speedfreak
4 Replies

10. Shell Programming and Scripting

List specific files from directories

Hello, I would like to list the files from all directories that has been modified more than 1 month ago, and whose name is like '*risk*log'. I think a script like this should work : ls -R | find -name '*risk*.log' -mtime 30 -type f But it tells me "no file found" though I can see some. ... (4 Replies)
Discussion started by: Filippo
4 Replies
Login or Register to Ask a Question